{% if '{posts}' in data.content %} {{ data.content.replace('{posts}', posts_html) | safe }} {% else %} {{ data.content | safe }} {% endif %}