Google app engine jinja2表单呈现不允许包含-&引用;
我正在尝试基于自定义表单模板。据我所知,Google app engine jinja2表单呈现不允许包含-&引用;,google-app-engine,django-forms,jinja2,Google App Engine,Django Forms,Jinja2,我正在尝试基于自定义表单模板。据我所知,render()只需向标记添加一些属性即可。例如,我添加了placeholder=“abc”,效果很好 {% call inserttourbus(id = "formAddNewRow" ) %} <div class="fieldWrapper"> {% if inserttourbus['bustype'].label() %}Bus Type{% endif %} {{ insertto
render()
只需向标记添加一些属性即可。例如,我添加了placeholder=“abc”
,效果很好
{% call inserttourbus(id = "formAddNewRow" ) %}
<div class="fieldWrapper">
{% if inserttourbus['bustype'].label() %}Bus Type{% endif %}
{{ inserttourbus['bustype'].render(placeholder="abc")|safe }}
{% if inserttourbus['bustype'].errors() %}Not filled yet!{% endif %}
</div>
{% endcall %}
因此,它将成为
{{ inserttourbus['bustype'].render(placeholder="abc", data-provide="typeahead", data-items="4", data-source='["Alabama","Alaska"]')|safe }}
但是jinja2引擎似乎不接受数据提供
,数据项
,等等,因为它包含“-”
字符。如果我将dataprovide
更改为dataprovide
,那么jinja2引擎可以很好地渲染代码
但是,在bootstrap typeahead
javascript中,所有变量都定义为数据提供
,数据项
。如果我将它们更改为dataprovide
,dataitems
,javascipt将停止工作
请给我一个解决方案:
-如何使jinja2接受带有“-”的属性
-在其他解决方案中,Python中使用连字符作为减法运算符。因此,不要在名称中使用它。当然,您可以在字符串中使用它。检查烧瓶中的操作。我想这对Django也会有同样的效果;在特定词典中传递具有无效Jinja2(Python)语法的HTML属性:
{{ inserttourbus['bustype'].render(placeholder="abc",
**{'data-provide':'typeahead',
'data-items':'4',
'data-source':'["Alabama","Alaska"]'}) }}
我将数据提供更改为数据u'\N{HYPHEN-减号}提供,但它不能节省我的时间。谢谢
{{ inserttourbus['bustype'].render(placeholder="abc",
**{'data-provide':'typeahead',
'data-items':'4',
'data-source':'["Alabama","Alaska"]'}) }}