Django和Chartjs模板冲突 [英] Django and Chartjs template conflict

查看:129
本文介绍了Django和Chartjs模板冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将折线图的 tooltipTemplate 属性设置为<%if(label){%><% = label%> ;:<%}%><%= value%> ,但是我在后端使用Django。因此,如果我尝试使用 tooltipTemplate 的字面值,Django将解释 {%%} 作为其模板语言的一部分。如何避免这种情况?

I'm trying to set the tooltipTemplate property of a line chart to <%if (label){%><%=label%>: <%}%><%= value %>, but I'm using Django on the backend. So, if I try to use the literal value of tooltipTemplate, Django will interpret the {% and %} as part of its template language. How can I avoid this?

tooltipTemplate:<%if(label){%><%= label%> ;: <%}%><%=值%>

推荐答案

使用 verbatim标签

{% verbatim %}
    tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>"
{% endverbatim %}

还有一个 templatetag标签,您可以使用它来输出特殊的模板标签字符,但这太冗长了。

There is also a templatetag tag which you can use to output special template tag characters, but that would be quite verbose.

tooltipTemplate: "<%if (label){% templatetag openblock %}><%=label%>: <%{% templatetag closeblock %}><%= value %>"

这篇关于Django和Chartjs模板冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆