certainlyakey
8/17/2017 - 2:27 PM

A way to move Twig block to different places in template (keeping the backend variables intact)

A way to move Twig block to different places in template (keeping the backend variables intact)

{% block meta %}

  {{ author_picture }}

{% endblock %}
<aside>
  
  {% block aside %}
  
    {# Set the default location of the meta #}
    {% use 'reused_block.twig' %}
  
    {% block aside_meta %}
      {{ block('meta') }}
    {% endblock %}
  
  {% endblock %}
  
</aside>

<article>

  {% block article %}
    {# empty for now #}
  {% endblock %}
  
</article>
{% extends 'parent.twig' %}

{# remove meta from its default location #} 
{% block aside_meta '' %}

{% block article %}
  {{ block('meta') }}
{% endblock %}