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?
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.