title: Append inline scripts inside Twig layout block
body: <p>I have a layout that looks like this:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
    &lt;!-- Omitted --&gt;
  
    &lt;div class="content"&gt;
      {% block body %}{% endblock %}
    &lt;/div&gt;
  
    &lt;script src="js/vendor.js"&gt;&lt;/script&gt;
    {% block javascripts %}
      &lt;!-- I want to be able to inject inline scripts from sub-templates here --&gt;
    {% endblock %}
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>Then I have the register_content.html.twig template overridden from FOSUserBundle and in it I am trying to inject script into the "javascripts" block like so:</p>
  
  <pre><code>{% block javascripts %}
    &lt;script&gt;
      // Some inline JS
    &lt;/script&gt;
  {% endblock %}
  </code></pre>
  
  <p>The problem I am having is the inline script seems to get injected at the end of the "body" block and not in the "scripts" block.</p>
  
  <p>This is the output I am getting:</p>
  
  <pre><code>      &lt;!-- This should be below js/vendor.js scripts --&gt;      
        &lt;script&gt;
          // Some inline JS
        &lt;/script&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script src="js/vendor.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>What am I doing wrong? Does my problem lie with FOSUserBundle and it's own templates it inherits from (it still uses my layout and everything I have in it; not it's own layout). I'm very confused here.</p>
  
  <p>P.S. I'm total newbie to Symfony/Twig so please be easy on me.</p>
  
  <p>EDIT: These are the FOSUserBundle layout and templates I have overriden:</p>
  
  <p>app/Resources/FOSUserBundle/views/layout.html.twig:</p>
  
  <pre><code>{% extends 'AcmeWebBundle::layout.html.twig' %}
  
  {% block title %}Acme Demo Application{% endblock %}
  
  {% block body %}
      {% block fos_user_content %}{% endblock %}
  {% endblock %}
  
  {% block javascripts %}
      {{ parent() }}
  {% endblock %}
  </code></pre>
  
  <p>app/Resources/FOSUserBundle/views/Registration/register.html.twig:</p>
  
  <pre><code>{% extends "FOSUserBundle::layout.html.twig" %}
  
  {% block body %}
      {% block fos_user_content %}
          {% include "FOSUserBundle:Registration:register_content.html.twig" %}        
      {% endblock fos_user_content %}
  {% endblock %}
  
  {% block javascripts %}
      {% parent() %}
  {% endblock %}
  </code></pre>
  
  <p>app/Resources/FOSUserBundle/views/Registration/register_content.html.twig:</p>
  
  <pre><code>&lt;div class="page-header"&gt;
      &lt;h2&gt;Register&lt;/h2&gt;
  &lt;/div&gt;
  
  &lt;form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register form-horizontal"&gt;
      &lt;!-- HTML Omitted --&gt; 
  &lt;/form&gt;
  
  {% block javascripts %}
      {% javascripts '@AcmeWebBundle/Resources/public/js/app.js' %}
      &lt;script&gt;
          // jQuery is undefined because it gets defined below the 'javascripts' block in the parent layout
          console.dir(window.jQuery);
      &lt;/script&gt;
      {% endjavascripts %}
  {% endblock %}
  </code></pre>