Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

274
Views
Visual Studio Code: Jinja Curly Braces inline for Javascript variable

I am trying to get Jinja braces to stay in line for a javascript variable used in an apexchart.js call for a flask HTML page.

labels = JSON.parse({{ labels | tojson}})

data = JSON.parse({{ data | tojson}})

The problem I am having is that when I save the html the braces get formatted apart.

    labels = JSON.parse({
        {
            labels | tojson
        }
    })
    data = JSON.parse({
        {
            data | tojson
        }
    })

Is there away to stop Visual Studio Code from splitting the Jinja code apart?

Current Code Below:


<!-- language: lang-html -->

    <!-- templates/index.html -->

    {% extends 'base.html' %} {% block content %}

    <title>Dashboard | {{title}}</title>
    <div class="flex h-screen justify-center">
        <div id="chart" class="h-1/4 w-1/2 content-center"></div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
    <script>
        labels = JSON.parse({
            {
                labels | tojson
            }
        })
        data = JSON.parse({
            {
                data | tojson
            }
        })
        var options = {
            colors: ['#01ca95'],
            chart: {
                type: 'bar'
            },
            dataLabels: {
                enabled: false
            },
            series: [{
                name: 'sales',
                data: data
            }],
            xaxis: {
                categories: labels
            },
            yaxis: {
                labels: {
                    formatter: function(data) {
                        //Setup new Formatting class variable 
                        var Formatter = new Intl.NumberFormat('en-US', {
                            style: 'currency',
                            currency: 'USD'
                        });

                        return Formatter.format(data);
                    }
                }
            },
        }
        var chart = new ApexCharts(document.querySelector("#chart"), options);

        chart.render();
    </script>

    {% endblock content %}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!