responsiv / campaign-plugin

[PREMIUM] Send professional campaign messages to your subscribers.
http://octobercms.com/plugin/responsiv-campaign
5 stars 2 forks source link

nl2br filter on textarea syntax field #46

Closed tschortsch closed 2 years ago

tschortsch commented 6 years ago

I would like to call the nl2br twig-filter on a textarea syntax field in my template. As I can't do this directly I tried to define a variable first like this:

{variable type="textarea" name="intro" label="Intro"}{/variable}
{{ intro|nl2br }}

Since this didn't work as expected I started analyzing the parsing related code. It seems that the twig syntax is parsed during the CmsController::render call in the getPageContent() function in models/Message.php. The SyntaxParser is called after this which means that this line {{ intro|nl2br }} is already replaced by the string intro before the variable gets parsed.

Wouldn't it be possible to change this behavoir that the SyntaxFields get parsed before the twig parser get's called? (like the RainLab.Pages plugin does).

daftspunk commented 2 years ago

Unfortunately, this is unsupported. It is a common request but it requires a rewrite of the plugin. We will look at adjusting the workflow to accommodate dynamic templates. At the moment the templates are statically rendered before the campaign launches.