gpt4 book ai didi

python - Jinja2:TemplateSyntaxError:遇到未知标签

转载 作者:太空狗 更新时间:2023-10-29 17:02:13 29 4
gpt4 key购买 nike

“我正在使用 Flask、Jinja2、higHighcharts”

示例(Python/ flask ):

@app.route("/column/")def column():    data=[{"data": [49.9, 54.4], "name": "Tokyo"}, {"data": [42, 30.4], "name": "AC"}]    return render_template('column.html', data=data)

Example(html,Jinja2,highcharts),my code is Wrong, and how to change it? Thank you!

Errormsg:jinja2.exceptions.TemplateSyntaxError
TemplateSyntaxError: Encountered unknown tag 'data'.

我正在使用 Highcharts-2.3.5\examples\column-basic\index.html

我改了但是报错,Flask log: "GET/column/HTTP/1.1"200

$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan',
'Feb'
]
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
shadow: true
},
tooltip: {
formatter: function() {
return ''+
this.x +': '+ this.y +' mm';
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: {{ data }} // i change
});
});

});

最佳答案

替换

series: {% data %}

series: {{ data }}

{{ variable }} 当你想使用从 python 脚本传递到模板的变量时使用。

关于python - Jinja2:TemplateSyntaxError:遇到未知标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14160414/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com