re: macros I'm trying to use one for an SVG sprite. But I'm not sure what I'm doing wrong.
macros template:
{% macro icon(iconId) %}
<svg class="icon icon-{{ iconId }}" role="img" title="{{ iconId }}">
<use xlink:href="{{ url('/assets/images/icons.svg#' ~ iconId) }}"></use>
</svg>
{% endmacro %}
In my layout template I have this {% import '_macros' as macros %}
and in an another template this {{ macros.icon("SIGNAL") }}
Then in the site i get a twig runtime error:
Accessing Twig_Template attributes is forbidden.
and it highlights the line where I extend the layout template.
Not sure why this isn't working.
Without a macro this code works fine. but I want the macro so I don't have to type it out all the time.
<svg class="icon" height="0" width="0">
<use xlink:href="/assets/images/icons.svg#SIGNAL" />
</svg>