[英]Django and Chartjs template conflict
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. 我试图将折线图的
tooltipTemplate
属性设置为<%if (label){%><%=label%>: <%}%><%= value %>
,但是我在后端。 So, if I try to use the literal value of tooltipTemplate
, Django will interpret the {%
and %}
as part of its template language. 因此,如果我尝试使用
tooltipTemplate
的字面值,Django将把{%
和%}
解释为其模板语言的一部分。 How can I avoid this? 如何避免这种情况?
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>"
You can use the verbatim tag . 您可以使用逐字标记 。
{% verbatim %}
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>"
{% endverbatim %}
There is also a templatetag tag which you can use to output special template tag characters, but that would be quite verbose. 还有一个templatetag标签 ,您可以使用它来输出特殊的模板标签字符,但这会很冗长。
tooltipTemplate: "<%if (label){% templatetag openblock %}><%=label%>: <%{% templatetag closeblock %}><%= value %>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.