How to render TWIG output to a variable for later use (symfony2)?

前端 未结 4 1406
说谎
说谎 2021-02-04 02:48

Instead of doing this rendering of each slide in my TWIG like this (see line 6):

{# loop out the slides #}
{% for c in contents %}
    {% set i=i+1 %} {# increas         


        
4条回答
  •  [愿得一人]
    2021-02-04 03:19

    Within a twig template, you can set the value of a printed variable like this:

    {% set rendered %}
      {{ var_to_print }}
    {% endset %}
    

提交回复
热议问题