Forum Discussion
Liquid: Can I add a variable to abort_message() function
Is there a way to pass in a variable or attribute when using abort_message() function?
I've checked the documentation but I can't see a way to do it.
I've tested variations and can only get plain text to work.
// this works
abort_message('my abort reason')
// this doesn't work
{% assign abort_reason = 'reason1' %}
abort_message({{reason1}})
abort_message('{{reason1}}')
The Braze documentation explicitly says that you can't use Liquid within the abort statement – you must use strings. That's not explained on the documentation page you've linked above, but it is on the connected content documentation page.
I imagine that you would conditionally assign a value to the abort_reason variable. Why not do the abort_message conditionally? Something along the lines of:
{% if criteria for abort reason 1 %}
{% abort_message('reason1') %}
{% elsif criteria for abort reason 2 %}
{% abort_message('reason2') %}
{% else %}
{% endif %}
3 Replies
- ArsoExpert
The Braze documentation explicitly says that you can't use Liquid within the abort statement – you must use strings. That's not explained on the documentation page you've linked above, but it is on the connected content documentation page.
I imagine that you would conditionally assign a value to the abort_reason variable. Why not do the abort_message conditionally? Something along the lines of:
{% if criteria for abort reason 1 %}
{% abort_message('reason1') %}
{% elsif criteria for abort reason 2 %}
{% abort_message('reason2') %}
{% else %}
{% endif %}- 2000andjamesSupporter
Thanks for the documentation.
Exactly, I'll continue with conditional statements.
- TedScottInfluencer
Taking it a step further, you cannot nest liquid (liquid inside of liquid), it's a limitation of liquid.
Related Content
- 7 days ago
- 11 months ago