Sejanus
Sejanus

Reputation: 3323

Symfony render template to string

Is there a way to get fully rendered template (with or without layout) as a string, within action?

i.e. something along these lines:

public function executeMyAction()
{
   $this->variable1 = 'foo';
   $this->variable2 = 'bar';

   // renders template using assigned variables, partials, layouts, etc. as if it was for    output to browser, but assigns html to string
   $renderedTemplate = $this->renderTemplateToString();
}

P.S. I am aware of this question, however the answer provided there isn't that good for my purposes. Links doesn't work and getPartial gets template file without rendering.

Upvotes: 3

Views: 1592

Answers (1)

greg0ire
greg0ire

Reputation: 23255

you should try sfController::getPresentationFor().

Upvotes: 5

Related Questions