I have to render a dropdown multiple times for the same user. Rather than call a macro or partial() every time, I'd like to run a macro once, capture the output, then repeatedly output what was captured.
Something like:
{%- macro dropdown(ids) %}
<select>
{% for id in ids %}
<option value = "{{id}}">{{id}}</option>
{% endfor %}
</select
{%- endmacro %}
{% set idSelect = dropdown([1,2,3]) %}
{{ idSelect }}
{{ idSelect }}
However, when compiled to PHP, the call to the dropdown macro causes it to generate output, rather than return it.
I know I could use raw PHP code & output buffering, but I was wondering if there was a cleaner or Volt-native way to do this.