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

146
Views
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 answers
Answer question

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 Report
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!