-
Notifications
You must be signed in to change notification settings - Fork 642
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
Error expected variable end #650
Comments
You can call functions, but you can't run arbitrary JS code (so no |
I use Gulp with Nunjucks. My solution is appending the var data = require('./templates/data.json');
data.year = new Date().getFullYear();
gulp.task('nunjucks', () =>
gulp.src('templates/*.njk')
.pipe(nunjucks.compile(data), options)
.pipe(rename(function (path) {
path.extname = ".html";
}))
.pipe(gulp.dest(''))
); Then in the
Output in the
|
You can call functions, but you can't run arbitrary JS code (so no new), and you can't access arbitrary JS globals, only values you explicitly pass into the template context (so no Date unless you pass it in yourself). mozilla/nunjucks#650 (comment)
I'm trying to call some function inside
{{ }}
and it gives error.I was trying to print current year:
How to do it right?
The text was updated successfully, but these errors were encountered: