nunjucks: nunjucks do not throw error when syntax error or none existing filter
hi guys, I have two templates: layout.nj
and home.nj
. home.nj
extends layout.nj
.
in somewhere of layout.nj
, I have some syntax error, such as
{% set tpl_now = Date.now() %}
or use a filter not defined
{{user.userId | raw | default("null") }}
when I run my node server, env.render
DO NOT throw error, and just return null
silently.
maybe it’s better to throw error in such cases, and so we can find out what is going wrong.
any advice is appreciated.
Thx in advance
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15
Commits related to this issue
- Fix bug where exceptions were silently swallowed with synchronous render fixes #678, #1116, #1127, and #1164. Closes #689 — committed to mozilla/nunjucks by fdintino 5 years ago
- Fix bug where exceptions were silently swallowed with synchronous render fixes #678, #1116, #1127, and #1164. Closes #689 — committed to mozilla/nunjucks by fdintino 5 years ago
I agree that the wording of the docs is vague. One would expect, with no callback provided, for an error to be thrown by
render()
@ArmorDarks thx. But according to the docs,
If I do not provide a callback, errors should be thrown.
You need to check error in a callback of
env.render
(first argument). If it exists, you must throw it on your own. See docs