Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jinja2: TemplateSyntaxError: Encountered unknown tag

"I am using Flask,Jinja2,higHighcharts"

Example (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'.

I am using Highcharts-2.3.5\examples\column-basic\index.html

I changed it but Error,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
        });
    });

});
like image 802
yiping Avatar asked Jan 04 '13 15:01

yiping


1 Answers

Replace

series: {% data %}

with

series: {{ data }}

{{ variable }} is used when you want to use a variable passed from the python script to the template.

like image 101
elssar Avatar answered Sep 30 '22 03:09

elssar