blueprint icon indicating copy to clipboard operation
blueprint copied to clipboard

Mailable should generate its template file

Open lintaba opened this issue 3 years ago • 6 comments

Synopsis:

Currently a mailable generates template with this:

        return $this->view('view.name');

I think it could be useful to generate the relevant template file too.

Proposed Syntax:

currently existing syntax could remain unchanged, or can be extended with a parameter, like view:email.reviewPost

      send: ReviewPost to:post.author with:post

Expected Behavior:

  • add an optional parameter to send statement (view). default value could be email.{mail}.
  • generate a view for this view path, if not exists.
  • pass the notification's parameters to the view, and maybe have a parameter hint at the begining of the view's file

lintaba avatar Oct 17 '21 12:10 lintaba

I'd be open to this if you'd like to start a PR. The only change I would make is a snake or kebab case template name (e.g. review-post.blade.php)

jasonmccreary avatar Oct 17 '21 23:10 jasonmccreary

snake/kebab is on the user. I made it to be fully optional and backward compatible, so you have to provide the view:foo-bar / view:fooBar. a decision that i made (which can be changed) is to prefix the view name with email. automatically, so its just view:reviewPost, and it creates the file as resources/views/emails/reviewPost.blade.php

lintaba avatar Oct 18 '21 14:10 lintaba

It's not on the user. Using snake is inline with how Blueprint generates other templates with compound words. Please update it.

jasonmccreary avatar Oct 18 '21 14:10 jasonmccreary

Copied from src/Generators/Statements/ViewGenerator.php:66 . Can you please send a counter example? Also is it also needed to be fixed?

lintaba avatar Oct 18 '21 14:10 lintaba

This receives the view which may have already been converted.

I am requesting it be changed to snake case. Please update the PR, or I can when I have time.

jasonmccreary avatar Oct 18 '21 15:10 jasonmccreary

@jasonmccreary fixed per your request

lintaba avatar Oct 21 '21 22:10 lintaba