Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use any variables #34

Open
gregistech opened this issue Apr 9, 2023 · 1 comment
Open

Can't use any variables #34

gregistech opened this issue Apr 9, 2023 · 1 comment

Comments

@gregistech
Copy link

gregistech commented Apr 9, 2023

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
Copy link
Author

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...

@gregistech gregistech changed the title Can't use custom tokens Can't use any variables Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant