Language Limitations

Double quotes in Twig tags within links

Double quotes cannot be used in Twig tags within links.

<a href="http://example.com/foo?source={{ cons.firstname | default("Friend") }}">

The workaround is to use single quotes where possible, or to set the variable in a separate statement and then reference the variable.

<a href="http://example.com/foo?source={{ cons.firstname | default('Friend') }}">
 {# or #}
 {%set source =  cons.firstname | default("Friend") }}
   <a href="http://example.com/foo?source={{ source }}">

Dynamic arguments in namespaced functions

Namespaced functions cannot accept variable arguments. This applies to personalization datasets, custom constituent fields, "in cons group", and signup form field custom fields. This means their arguments must be hard-coded in the function call.

Functions that must have their arguments hardcoded:

  • cons.inConsGroup
  • custom_dataset.custom_dataset
  • cons_field.value
  • signup_form_field.value
{% set group = 1 %}
{%if cons.inConsGroup(group) %}

Must be:

{%if cons.inConsGroup(1) %}

If you need to conditionally set different values for these functions, you can do so using if statements to control the flow:

{% if cons.firstname %}
  {% if cons.inConsGroup(1) %} condition... {%endif%}
{% else %}
  {% if cons.inConsGroup(2) %} other condition... {%endif%}
{% endif %}

This limitation does not apply to non-namespaced functions (like Twig Link functions).