Logicify / mautic-advanced-templates-bundle

Plugin extends default email template capabilities with TWIG block so you can use advanced scripting techniques like conditions, loops etc
https://logicify.com/?utm_source=github&utm_campaign=mautic-templates&utm_medium=opensource
MIT License
86 stars 57 forks source link

Can't use any variables #34

Open gregistech opened 1 year ago

gregistech commented 1 year ago

I can't seem to get custom tokens variables to work in the subject/body.

My main use case: I want to specify the subject from the API. How I send the custom tokens work in the vanilla templating system, but Twig doesn't get them. Template: Subject: {% TWIG_BLOCK %}{% subject %}{% END_TWIG_BLOCK %} Body:

{content}

{signature}

{unsubscribe_text}

Request: POST https://mautic.varigergo.hu/api/emails/EMAIL_ID/contact/CONTACT_ID/send

{ "tokens": { "subject": "xxxx", "content": "xxxxx" } }

Error:

[2023-04-09 13:37:09] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\SyntaxError: "Unknown "subject" tag in "__string_template__63495053935a5082041ab9769b6c41ccf06b0329b0eeb8cb21a49cc072432a2c" at line 1." at /var/www/html/vendor/twig/twig/src/Parser.php line 160 {"exception":"[object] (Twig\\Error\\SyntaxError(code: 0): Unknown \"subject\" tag in \"__string_template__63495053935a5082041ab9769b6c41ccf06b0329b0eeb8cb21a49cc072432a2c\" at line 1. at /var/www/html/vendor/twig/twig/src/Parser.php:160)"} {"hostname":"ae6df2b3b54a","pid":50}
gregistech commented 1 year ago

Interestingly, nothing works:

[2023-04-09 13:58:05] mautic.CRITICAL: Uncaught PHP Exception Twig\Error\SyntaxError: "Unknown "lead" tag in "__string_template__18b092cad8de03ef76402f7817cbd7520c925b89360e4bbd29fd19bc09400f63" at line 1." at /var/www/html/vendor/twig/twig/src/Parser.php line 160 {"exception":"[object] (Twig\\Error\\SyntaxError(code: 0): Unknown \"lead\" tag in \"__string_template__18b092cad8de03ef76402f7817cbd7520c925b89360e4bbd29fd19bc09400f63\" at line 1. at /var/www/html/vendor/twig/twig/src/Parser.php:160)"} {"hostname":"ae6df2b3b54a","pid":49}

So actually, no variable is available...