LastCallMedia / Mannequin

Mannequin Component Theming Tool
https://mannequin.io/
MIT License
38 stars 8 forks source link

Guarded Twig metadata in blocks cannot be used in a child template #71

Closed rbayliss closed 7 years ago

rbayliss commented 7 years ago

Twig metadata that is kept in blocks, eg:

{% if _component %}{% block componentinfo %}
name: Foo
...
{%endblock %}{% endif %}
The rest of the template.

This metadata will cause parse errors if the template inherits from another template (Node "1" does not exist for Node "Twig_Node"). Because of this, I don't think we are going to be able to use inline blocks to contain that Twig metadata. Instead, we could parse the metadata out of a special comment, eg:

{# @Component
name: Foo
...
#}
The rest of the template.

I actually like this solution better anyway, since it will be completely ignored when the template is rendered outside of Mannequin.

This is a high priority fix because it affects our primary use case (Drupal), and will be a fairly common occurrence. I'm not sure how we got through the initial release without finding this.