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
Closed

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

sergeyklay opened this issue Feb 13, 2019 · 8 comments
Assignees
Labels
enhancement Enhancement to the framework

Comments

@sergeyklay
Copy link
Contributor

sergeyklay commented Feb 13, 2019

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

$html = $view->toString($template, $params);
mail("[email protected]", "My subject", $html);

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

@niden niden added the enhancement Enhancement to the framework label Feb 13, 2019
@niden niden self-assigned this Feb 13, 2019
@dschissler

This comment was marked as abuse.

@Jeckerson
Copy link
Member

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

@JABirchall
Copy link

@ViltusVilks
Copy link

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
Copy link
Contributor

Jurigag 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 mentioned this issue May 10, 2019
4 tasks
niden added a commit that referenced this issue May 12, 2019
niden added a commit that referenced this issue May 12, 2019
@niden
Copy link
Member

niden commented May 12, 2019

Resolved in #14058

@niden niden closed this as completed May 12, 2019
@niden niden added the 4.0 label Jun 21, 2019
@EcLaboratory
Copy link

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
Copy link
Member

niden 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
Labels
enhancement Enhancement to the framework
Projects
None yet
Development

No branches or pull requests

8 participants