TerrePorter / StringBladeCompiler

Render Blade templates from string
MIT License
175 stars 75 forks source link

Not working for mailables #36

Closed martijnc94 closed 5 years ago

martijnc94 commented 6 years ago

I am using the new version 3.6.0

When returning a view in a controller:

return view (['template' => '{{$token}}'], ['token' => 'I am the child template']);

Works fine, but when trying to create a Mailable:

return $this->view (['template' => '{{$token}}'], ['token' => 'I am the child template']);

Creates an empty mail. When I set a file as template, it works fine.

martijnc94 commented 6 years ago

I now use a workaround:

rendering the template like this: $this->content = \View::make(['template' => '{{$token}}'], ['token' => 'I am the child template'])->render();

and injecting that rendered template as a variable in a template file with contents: "{!! $content !!}"

TerrePorter commented 6 years ago

@martijnc94 I think that is the work around for mailable. I think something similar was mentioned in this ticket https://github.com/TerrePorter/StringBladeCompiler/issues/21

kyawkyawsoezhu commented 5 years ago

@martijnc94 if you don't want to create extra blade file you can try this way.

$html = view(['template' => '{{$token}}'], ['token' => 'I am the child template']);
return $this->html($html->render());
martijnc94 commented 5 years ago

@kyawkyawsoezhu That's the way I eventually figured out.