I add pictures over assetic like this:
{% image '@MyBundle/Resources/public/img/name.png' %}
<img src="{{ asset_url }}"/>
{% endimage %}
works fine for me, but I would like to write less, so I tryed to create a twig function like in the symfony2 docu. But I don't use any filter:
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles: [MyBundle]
#java: /usr/bin/java
filters:
cssrewrite: ~
twig:
functions:
timg: ~
But if I now use it:
<img src="{{ timg('@MyBundle/Resources/public/img/name.png') }}" />
I get the exception:
An exception has been thrown during the compilation of a template ("Catchable Fatal Error: Argument 3 passed to Twig_Node_Expression_GetAttr::__construct() must be an instance of Twig_Node_Expression_Array, instance of Twig_Node given, called in C:\wamp2\www\symfony\vendor\symfony\assetic-bundle\Symfony\Bundle\AsseticBundle\Twig\AsseticNodeVisitor.php on line 66 and defined in C:\wamp2\www\symfony\vendor\twig\twig\lib\Twig\Node\Expression\GetAttr.php line 14") in "::top.html.twig".
Any ideas? Maybe I can't use just function for short syntax without a filter?