Jinja2:TemplateSyntaxError:遇到未知标签

问题描述 投票:15回答:1

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

示例(Python / Flask):

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

示例(html,Jinja2,highcharts),我的代码有误,如何更改?谢谢!

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

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

我更改了它,但错误,烧瓶日志:“ 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
        });
    });

});
python highcharts flask jinja2
1个回答
36
投票

替换

series: {% data %}

with

series: {{ data }}

[{{ variable }}用于当您要使用从python脚本传递到模板的变量时。

© www.soinside.com 2019 - 2024. All rights reserved.