Hi everyone,
my goal is to render small blocks of html inside of a for loop. My idea was, to define a macro which then can be used in my for loop. The problem is, that the name of the macro is part of the loop data.
For example I define a macro like this:
{% macro myMacroTitle() %}
Here comes the html content.
{% endmacro %}
Later I want to display the content of the macro like this:
{% for name, element in myelements %}
This is the content of {{ name }}:
{% element.macroTitle() %}
{% endfor %}
Is it possible to call a macro with a title held in a variable? Or is there some other way (not partials in separate files) to render content with a name stored in a variable?
Thans in advance,
HansPeter