title: Capture and append in Twig
body: <p>What I need is to append text blocks to the same name in any template and finally print its value.</p>
  
  <p>What I have so far.</p>
  
  <p>In child template:</p>
  
  <pre><code>{% set tmp %}
  ...some text...
  {% endset %}
  
  {% set capture = capture|default([])|merge([tmp]) %}
  </code></pre>
  
  <p>In parent (main layout):</p>
  
  <pre><code>{{ capture|default([])|join|raw }}
  {# it works in the same template but not in parent #}
  </code></pre>
  
  <p>I know it is ugly but still would be happy if it worked.</p>
  
  <p>Ideally I'd like to make an extension to work like this:</p>
  
  <pre><code>{% capture %}
  ...some text...
  {% endcapture %}
  {# to capture #}
  
  {% capture() %}
  {# to print #}
  </code></pre>
  
  <p>but documentation that I've seen (<a href="http://twig.sensiolabs.org/doc/advanced.html" rel="nofollow">http://twig.sensiolabs.org/doc/advanced.html</a>) does not help.</p>
  
  <p>I don't know what type of extension should I choose, where actual data manipulations are made, how I access and append data.</p>
  
  <p>What existing extension could I use as a base?</p>