pebble icon indicating copy to clipboard operation
pebble copied to clipboard

Error passing named arguments to macros when using named imports

Open brettatoms opened this issue 3 years ago • 1 comments

Given the following macro saved in the file forms.html:

{% macro input(type="text") %}
    <input type="{{ type }}"  />
{% endmacro %}

If you import forms.html without assigning the import to a variable then using named arguments works fine, e.g:

{% import "forms" %}
{{ input(type="text") }}

But if you import forms.html and set it as a variable then passing named arguments throws a ParserException with the message "Can not use named arguments when calling a bean method", e.g.

{% import "forms" as forms %}
{{ forms.input(type="text") }}

brettatoms avatar Dec 12 '22 02:12 brettatoms

current implementation does not support named arguments , you can work around like this: ··· {% import "forms" as forms %} {{ forms.input("text") }} ···

yanxiyue avatar Jun 10 '23 15:06 yanxiyue