title: Symfony2 Twig Inject additional blocks
body: <p>Is there a way with Symfony2 and Twig to always make files available which just contain blocks.</p>
  
  <p>For example, if I wanted to make a block named 'cookie' always available in any template in my system, without having to always include or extend it in the template I'm using.</p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>Clarification</p>
  
  <p>Say I have a generic block which can do something, like:</p>
  
  <pre><code>{% block myBlock %}
      ABC Examples
  {% endblock %}
  </code></pre>
  
  <p>I have a class which knows it wants to be rendered with this block. My template itself doesn't necessarily know this though.</p>
  
  <pre><code> {{ block(myObj.blockName) }}
  </code></pre>
  
  <p>I would then like to have it so my controller/services/etc. could register the file which contains that block, without my template actually needing to know about it directly (so I could have multiple files like that, each working with some common interface).</p>
  
  <p>Similar to registering custom Twig functions with a TwigExtension. My template doesn't need to explicitly know it's there, it just has to be available at run-time.</p>
  
  <p>Does that make sense?</p>
  
  <hr>
  
  <p>To clarify a bit further, I'm essentially looking to do something just like how there are default Twig blocks for rendering Forms in Symfony2. I don't have to include the default form file every time, just when I want to change something.</p>