Latte (Nette) PHP framework - disable escaping globally (automatically add "noescape")

811 Views Asked by At

I am using Latte framework to generate Email templates in my application. I don't need escaping in variables used in template because I use it for inline CSS styling that escaping incorrectly. To avoid escaping I need to use:

{$style['.ei-section-rows-wrapper']|noescape}

I have a lot of tags with inline styles and adding "|noescape" everywhere breaks readability of HTML template file.

Is this possible to globally set some configuration for Latte framework to NOT escape anything in my template? I assume I can set some params after this code:

$latte = new Latte\Engine;

// Add some custom filter to $latte to disable escaping?..

$email_template = $latte->renderToString(....);
2

There are 2 best solutions below

0
On

{contentType text} turns off escaping completely; see https://latte.nette.org/en/tags#toc-contenttype

0
On

I am afraid that there is no official way how to turn off auto-escaping in Nette framework yet.