-
Notifications
You must be signed in to change notification settings - Fork 640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nunjucks do not throw error when syntax error or none existing filter #1116
Comments
You need to check error in a callback of |
@ArmorDarks thx. But according to the docs,
If I do not provide a callback, errors should be thrown. |
@ArmorDarks I have tried the But nunjucks still catch error silently when syntax error . |
hm, well, never used it (because it's async, so you need to use callback anyway). Might be a bug
Am I missing something? Where exactly there a syntax error? |
@ArmorDarks seems like nunjucks do not support javascript native code. see #419 and #650(comment).
|
seems like I've missed something.
|
|
@ArmorDarks yes, |
Are you sure that you're properly passing Date to Nunjucks? I've tested with Also, are you sure that you're not using |
@ArmorDarks here is my case: I have a block in <!doctype html>
{% block block_assign %}
{% set test_val = "hello" %}
{% set tpl_now = Date.now() %}
{% endblock %}
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script>
window.tplConf = {
user : {
now: '{{ tpl_now }}',
test_val: '{{ test_val }}'
},
};
</script> later in my template, accessing |
This is correct. Block creates a kind of closure or scope, so you can't access variables, defined within it, outside of it. If you want to access them outside, you need to define them outside of the block too. |
@ArmorDarks thx a lot |
I agree that the wording of the docs is vague. One would expect, with no callback provided, for an error to be thrown by |
It took me a really long time to realize that there was an error in my code thinking that if there was nunjucks would complain, but apparently it only complains if there's a callback, and... yeah. Agreed. |
hi guys, I have two templates:
layout.nj
andhome.nj
.home.nj
extendslayout.nj
.in somewhere of
layout.nj
, I have some syntax error, such asor use a filter not defined
when I run my node server,
env.render
DO NOT throw error, and just returnnull
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
The text was updated successfully, but these errors were encountered: