Answers.Body: <p>I'm going to assume that, as per the use cases <a href="https://twig.sensiolabs.org/doc/1.x/tags/embed.html" rel="nofollow noreferrer">in the documentation</a>, <code>embed</code> is a good fit for your requirements.</p>
  
  <p>If you're not sure, <code>extends</code> and <code>include</code> are probably a better choice, as they're much easier to understand and work with.</p>
  
  <p>Moving on, in your example you appear to have confused the roles of the template being embedded, and the template doing the embedding.</p>
  
  <p>Here's how it should look:</p>
  
  <pre><code>{# Page (doing the embedding) #}
  {% embed "_partials/sidebar" %}
      {% block subscribe %}
          The custom subscribe block content.
      {% endblock %}
  {% endembed %}
  
  {# Embed (being embedded) #}
  &lt;div class="sidebar"&gt;
      &lt;div class="sidebar__subscribe"&gt;
          {% block subscribe %}
              The (optional) default subscribe block content.
          {% endblock %}
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-05T19:12:15.257Z
Answers.LastActivityDate: 2017-05-05T20:22:13.210Z
Answers.LastEditDate: 2017-05-05T20:22:13.210Z
Answers.UserDisplayName: Stephen Lewis
Body: <p>I'm trying to embed the sidebar and define which blocks to display.</p>
  
  <pre><code>{% embed "_partials/sidebar" %}
      {% block instagram %}{% endblock %}
      {% block subscribe %}{% endblock %}
  {% endembed %}
  </code></pre>
  
  <p>sidebar.html is </p>
  
  <pre><code>{% block subscribe %}
      block content
  {% endblock %}
  </code></pre>
  
  <p>But it doesn't show anything and no errors as well (dev mode enabled).</p>
  
  <p>The idea is make a dynamic sidebar and define which widgets I'd like to see in each template.</p>
  
  <p>This is what I use right now.</p>
  
  <pre><code>        {% set widgets = {
              'about'     : true,
              'instagram' : true,
              'menu'      : false,
              'recipes'   : true,
              'subscribe' : true
          } %}
  
          {% include "_partials/sidebar" with {
              widgets: widgets
          } %}
  </code></pre>
  
  <p>sidebar.html</p>
  
  <pre><code>       {% if widgets.menu == 'true' %}
             content
         {% endif %}
  </code></pre>
  
  <p>is there any other more flexible approaches for this?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-05-05T18:56:45.023Z
Comments.Text: I've personally never found a good reason to use `embed`. It's a strange tag... I use `extends` and `include` 100% of the time.
Comments.UserDisplayName: Lindsey D
Tags: <embed>
Title: Trouble with Twig `embed` tag
ThreadText: # Trouble with Twig `embed` tag
  
  (Asked by: username_0 on 2017-05-05)
  
  I'm trying to embed the sidebar and define which blocks to display.
  
  ```
  {% embed "_partials/sidebar" %}
      {% block instagram %}{% endblock %}
      {% block subscribe %}{% endblock %}
  {% endembed %}
  
  ```
  
  sidebar.html is
  
  ```
  {% block subscribe %}
      block content
  {% endblock %}
  
  ```
  
  But it doesn't show anything and no errors as well (dev mode enabled).
  
  The idea is make a dynamic sidebar and define which widgets I'd like to see in each template.
  
  This is what I use right now.
  
  ```
          {% set widgets = {
              'about'     : true,
              'instagram' : true,
              'menu'      : false,
              'recipes'   : true,
              'subscribe' : true
          } %}
  
          {% include "_partials/sidebar" with {
              widgets: widgets
          } %}
  
  ```
  
  sidebar.html
  
  ```
         {% if widgets.menu == 'true' %}
             content
         {% endif %}
  
  ```
  
  is there any other more flexible approaches for this?
  
  **Tags:** embed
  
  > **Comments:**
  > **username_1**: I've personally never found a good reason to use `embed`. It's a strange tag... I use `extends` and `include` 100% of the time.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-05-05. Score: 2
  
  I'm going to assume that, as per the use cases [in the documentation](https://twig.sensiolabs.org/doc/1.x/tags/embed.html), `embed` is a good fit for your requirements.
  
  If you're not sure, `extends` and `include` are probably a better choice, as they're much easier to understand and work with.
  
  Moving on, in your example you appear to have confused the roles of the template being embedded, and the template doing the embedding.
  
  Here's how it should look:
  
  ```
  {# Page (doing the embedding) #}
  {% embed "_partials/sidebar" %}
      {% block subscribe %}
          The custom subscribe block content.
      {% endblock %}
  {% endembed %}
  
  {# Embed (being embedded) #}
  <div class="sidebar">
      <div class="sidebar__subscribe">
          {% block subscribe %}
              The (optional) default subscribe block content.
          {% endblock %}
      </div>
  </div>
  
  ```
  
  
  ---
  
  