You can use operators like + to combine strings inside expression blocks. If statements If statements in Jinja look like this: {% if message['role'] == 'user' %} {{ message['content'] }} {% endif %} Note how where Python uses whitespace to mark the beginnings and ends of for and if blocks, Jinja requires you to explicitly end them with {% endfor %} and {% endif %}. Special variables Inside your template, you will have access to the list of messages, but you can also access several other special variables.