Template tags

switchoff

Template tag that conditionally renders a block if a named switch is off.

switchoff is like an if/else that renders content conditionally based on the active variant of an experiment. switchoff is similar to the variant tag, but with the implicit variant 'off' for the primary block and 'on' for the else block.

To use switchoff with an experiment, it should declare only on or off as variants.

Example:

{% switchoff "super_cool_feature" %}
    Content displayed if the switch is off
{% else %}
    Optional content displayed if the switch is on...
{% endswitchoff %}

switchon

Template tag that conditionally renders a block if a named switch is on.

switchon is like an if/else that renders content conditionally based on the active variant of an experiment. switchon is similar to the variant tag, but with the implicit variant 'on' for the primary block and 'off' for the else block.

To use switchon with an experiment, it should be configured as a switch: declare only on or off as variants.

Example:

{% switchon "super_cool_feature" %}
    Content displayed if the switch is on
{% else %}
    Optional content displayed if the switch is off...
{% endswitchon %}

variant

Renders content based on active experiment variants, similar to if/elif/ else.

variant and elif blocks can take one or more variant. If no named variants are active the else block, if provided, will be rendered.

Example:

{% variant "experiment_name" "variant_A" "variant_B" %}
    Content for variant A or B...
{% elif "variant_C" %}
    Optional Content for variant C...
{% else %}
    Optional fallback content...
{% endvariant %}