Twig Documentation

This page will help you get started with BSD Twig.

The BSD Mailing module has the ability to send out mailings with conditional content, which will give recipients different text based on the logic written in a template. The templating language this is based on is called Twig

You can learn more about its functionalities by reading the language documentation. BSD is currently using Twig version 1.16.1

The kinds of features supported by the Twig templating language include:

  • Variables (replacement of placeholder text with corresponding value per constituent). e.g. {{ cons.name }}
  • Conditionals (if/else) e.g. {% if cons.name == "Barack Obama" %} Dear Mr. President {%endif%}
  • Loops (see the example below for Representatives)
  • Text manipulation (upper-case text, lower-case text, round a number, etc). e.g. {{ hpc_raw | round }}
  • Comments (that will be removed from the body of the email before sending). e.g. {# This won't appear in the email #}

Below is a very detailed description of functionality that can be achieved with TWIG and the mailer, in addition to some language tips and code samples.