Repeating Items Within Text

All of these options can be easily inserted using the Word add-in without learning code:

Intersperse with Other Text (Instead of a List or Table)

Repeating Question attributes can be used with other text, like this:

Here are the children's names:

{% for item in children %} {{ item.firstname }}, {% endfor %}

Adding Commas & "and" in a List of Repeating Items (e.g., Jack, Jane and Jill)

If you want to write out your list of items and separate them out with commas and an "and," here is the syntax.  Only the ItemName and ItemAttribute will change based on your variables:

Comma

{{ commalist(itemname, '<itemattribute>') }}</itemattribute>

Example: Jane, Jack and Jill

Oxford Comma

{{ commalistoxford(itemname, '<itemattribute>') }}</itemattribute>

Ex.: Jane, Jack, and Jill

Semicolon

{{ semicolonlist(itemname, '<itemattribute>') }}</itemattribute>

Ex.: Jane; Jack; and Jill

Other Separator (useful for other languages)

{{ customseparatorlist(itemname, '<itemattribute>', ‘separator’, ‘finalseparator’) }}</itemattribute>

Example:

{{ customseparatorlist(children, '<childname>', ‘,’, ‘y’) }}</childname>

Gives us: Jane, Jack y Jill  

Example with multiple attributes

Here is an example where we have both childname, additional text, and the child's date of birth listed in between "and" statements.  Make sure all your attributes go within the ' ', or just use our Word add-in to do this all for you!

{{ commalist(children, '<childname> born on <childdob>') }}</childdob></childname>

Jane born on 1/1/91, Jack born on 1/1/90 and Jill born on 1/1/89


Special Case: Capitalizing or Bolding Only a Single Attribute of the Repeating Item

Upper Case: If you want to capitalize (all caps) any attribute of the list, you can do so by adding .upper() like this:

{{ commalist(ItemName, "<ItemAttribute> <ItemAttribute2.upper()>") }}

 

Bold: If for some reason you can't use the List Comma option above (which is also in the Word add-in).  For example if you want to bold just one repeating item attribute, you can also use this syntax to add an "and" before the last option.  If you bold the ItemAttribute, it will appear bolded in your final document.

{% for item in ItemName %}{% if  not loop.last and not loop.first %}, {% elif loop.last %} and {% endif %}{{ item.ItemAttribute|upper }}{% endfor %}.