Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFR] Create a view method to simple render template to a string. #13825

Closed
sergeyklay opened this issue Feb 13, 2019 · 8 comments

Comments

Projects
8 participants
@sergeyklay
Copy link
Member

commented Feb 13, 2019

As a regular user I would like to have something like this:

$html = $view->toString($template, $params);
mail("someone@example.com", "My subject", $html);

without setting any additional params eg base path, layout, base template, etc.

@niden niden added this to To do in 4.0 Release via automation Feb 13, 2019

@niden niden added the Enhancement label Feb 13, 2019

@niden niden self-assigned this Feb 13, 2019

@dschissler

This comment has been minimized.

Copy link
Contributor

commented Feb 14, 2019

Since when are you a normal user?

Perhaps a third parameter for using a file path to read with file_get_contents.

$html = $view->toString($template, $params);
$html = $view->toString($templatePath, $params, true);
@Jeckerson

This comment has been minimized.

Copy link
Member

commented Feb 15, 2019

This is actually useful. Not only for email templates, but for ajax responses when you need to return rendered html inside json.

@JABirchall

This comment has been minimized.

Copy link

commented Feb 15, 2019

@ViltusVilks

This comment has been minimized.

Copy link

commented Feb 15, 2019

As I remember it is not so trivial. GetRender triggers events and can break something at the end. Partial can be used.

Otherwise only forking can do safe render.

@Jurigag

This comment has been minimized.

Copy link
Member

commented Feb 25, 2019

@JABirchall you still have here controllerName and actionName. Right now this can be achieved by some hacky way - like simply create temporary new volt template in /tmp and then render it, but this is just workaround.

@niden niden moved this from To do to In progress in 4.0 Release May 10, 2019

@niden niden referenced this issue May 10, 2019

Merged

T13825 view tostring #14058

4 of 4 tasks complete

niden added a commit that referenced this issue May 12, 2019

niden added a commit that referenced this issue May 12, 2019

@niden

This comment has been minimized.

Copy link
Member

commented May 12, 2019

Resolved in #14058

@niden niden closed this May 12, 2019

4.0 Release automation moved this from In progress to Done May 12, 2019

@niden niden added the 4.0 label Jun 21, 2019

@EcLaboratory

This comment has been minimized.

Copy link

commented Jun 24, 2019

Watching the changes in code it seems the only real change is not to fire events. Is it planned to make available a method to do the action an the begining of this blog exposed?

I mean

$html = $view->toString($template, $params);

where $template is an string with the volt template content and $params an array to use to render the template

Thanks in advance

@niden

This comment has been minimized.

Copy link
Member

commented Jun 24, 2019

@EcLaboratory This particular change is for the View which will take a template as a controller/action/view and will load it and send it back.

If you want a specific template to be parsed and returned, you can use the View\Simple component which does the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.