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

140
Vistas
Why does nunjucks fail silently on bad syntax while compiling, or bad data while rendering?

While editing my templates, if I make a mistake, say for example I leave off a closing tag, as in...

{% if variable %}
  Notice there is no closing tag within this template!

When compiling this, nunjucks seems to remain silent. I don't see an exception or console.log. Is this the intended experience? Is there a config flag to turn on "die loudly if anything is wrong"?

The same applies during rendering. If my template is fine, but I render it with data that does not match, it seems to silently fail. Is it supposed to fail quietly, not throw any exceptions, not log to the console?

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

0

It's all my fault. Nunjucks does throw exceptions for this sort of thing. The exception was being lost because of how I was using the jQuery promises library. The source explains it very nicely...

// Support: Promises/A+ section 2.3.3.3.4.1
// https://promisesaplus.com/#point-61
// Ignore post-resolution exceptions
if ( depth + 1 >= maxDepth ) {

The idea is, if the .then() handler of a promise throws an exception, the promises library catches that exception. The promise's .fail() handler is then called. If the promise doesn't have a fail handler, that's when the exception is "lost". By using promises, I bought in to the error handling story of promises.

It wasn't nunjucks' fault.

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