Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
Fix @ Jinja variable parsing at Javascript code in a static JS file …?

I am running into this “old problem”: Jinja variable parsing only works on the html template (passed in to render_template), so if your Javascript code is in a static JS file the Flask/Jinja variables can't be accessed”. Jinja Flask issue: Uncaught SyntaxError: Unexpected token { in JSON at position 1 at JSON.parse Does anyone know if there is already a solution for this. It's ugly to embed the JS code in the HTML file

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use the tojson Jinja filter to safely embed only the JSON data into the document, then load it in JS.

{% set data = [1, 2, 3, 4] %}
<script id="data" type="application/json">{{ data|tojson }}</script>

And in the external JS file:

const value = JSON.parse(document.getElementById('data').textContent);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda