That is common issue when using dictionary literals in Python.
my_dict = {
key: value
}
Require you to have variables named key
and value
defined, so in fact
key = 1
value = 0
my_dict = {
key: value
}
Will create your dictionary, the same as:
my_dict = {
1 : 0
}
So if you wanted to have dictionary where entry key is 'key'
you have to quote it
my_dict = {
'key': 'value'
}
Jinja2 templates are no different:
{% macro field(field, label='', form_label={class:""},form_field={class:""}) -%}
There are two issues here:
Replace it with:
{% macro field_macro(field, label='', form_label={'class':""},form_field={'class':""}) -%}
And of course:
{{ field_macro(form.username, label=_("Username"), form_label={'class':"col-xs-2"},
form_field={'placeholder':_("Enter your")+" "+_("Username"),
'class':"form-control focused required"}) }}
Another gotcha here, are default function parameters.
If by any chance you will change form_field within macro (you can do it in jinja) when default paramter was used ( ie nothing was passed for that parameter), all other calls with no parameter will use changed value.