Symfony Get Raw Data from Function in Template

If you’re in a template in Symfony, and you have your output escaping enabled, one thing that bugged me was when I tried to do this:

$my_model->getMyOutput('param1','param2');

The output would be escaped – for example I’d get “<b>this is bold</b>” rather than “this is bold“. The usual $my_model->getRaw(’MyOutput’) didn’t help, as it doesn’t accept parameters (actually I expected it to take an optional second parameter, being an array of parameters, and was quite suprised to find that wasn’t the case).

A quick note – incase you weren’t already aware – calling $model->getRaw(’Column’); will get the unescaped version of $model->getColumn;

The solution is there, sitting happily in the documentation. But I want to give you a Google insta-answer. What you need to do is put ESC_RAW as the last parameter:

$my_model->getMyOutput('param1','param2',ESC_RAW);

Then your template gets the raw output of the function you’re calling, rather than automagically escaping the data for you.

Trackback URL

,

No Comments on "Symfony Get Raw Data from Function in Template"

Hi Stranger, leave a comment:

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Subscribe to Comments