我正在尝试在jinja模板中编写if语句
{% for key in data %}
{% if key is 'priority' %}
<p>('Priority: ' + str(data[key])</p>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我试图在python中翻译的声明是
if key == priority:
print(print('Priority: ' + str(data[key]))
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
TemplateSyntaxError:期望令牌'name',得到'string'
我正在尝试添加一条垂直线,以便在元素超出值时可以有视觉区别.
谢谢
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
["Element", "Difference", {
role: "style"
}],
["FOLDERADDUPDATE", 2.29, "#e5e6e2"],
["NOTEUPDATE", 3.63, "silver"],
["DELETENOTE", 1.12, "e5e4e7"],
["NOTEUPDATEANDFOLDER", 5.02, "color: #e5e4e2"],
["FOLDERREMOVEUPDATE",.082,"color:e5e5e2"],
["PENDINGEVENT", 0,"color:e5e4e4"]
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, {
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation"
},
2]);
var options = {
title: "",
width: 600,
height: 300,
bar: {
groupWidth: "95%"
},
legend: {
position: …Run Code Online (Sandbox Code Playgroud)