News for hackers. Stuff that matters.
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by darrhiggs on Thursday October 24, 2013 @05:41PM (#6608196)
Personally I settled on swig[1] for a recent project. My reasoning being that Nunjucks may contain more features, but, I prefer a constrained set of features that forces me to think twice before I implement & use logic in a view.

It's a great project anyway and it did take 2-3 weeks to decide between the two. Good luck with the project!

[1] http://paularmstrong.github.io/swig/

Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by jlongster on Thursday October 24, 2013 @05:58PM (#6608302)
Fair enough! Swig is an interesting project too.

The problem I have with swig is that it takes a lot of shortcuts for speed and simplicity of the code. For example, if you have a js function that you call in your template, like {{ foo() }}, the output is not autoescaped ever, regardless of your autoescaping setting. That's dangerous.

Would it help if nunjucks had a "strict" mode that removed a few tags like "set"?

EDIT: that and it seems to be completely against precompiling templates for the browser, which is insane

Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by v13inc on Thursday October 24, 2013 @06:40PM (#6608528)
I'm really excited to check out this Nunkucks project. I ended up evaluating a bunch of JS Jinja-style libraries and also ended up choosing SWIG.

Unfortunately, SWIG does not run well in the browser. The code is converted with Browserify, and the browser tests only cover the simplest use cases of the library. Thinks broke down horribly as soon as you used a tag ({% extends %}, {% include %}) that needs to load a template.

Is the browser a first-class citizen with Nunjucks? I'd like a library that supports 100% of the features (including compiling templates) in the browser.

Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by jlongster on Thursday October 24, 2013 @06:44PM (#6608552)
Absolutely. We run 100% of the tests in the browser, and you can run them by going here: http://jlongster.github.io/nunjucks/files/tests/browser/

If you want to optimize in production, there is advanced support for precompiling your templates as well: http://jlongster.github.io/nunjucks/api.html#precompiling

Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by curiouslearn on Friday October 25, 2013 @10:45PM (#6616043)
This is an awesome templating engine. I have heard about so many javascript templating engines, but not this one before, despite the fact that this appears to be better than all of them.
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by coolsunglasses on Thursday October 24, 2013 @09:37PM (#6609251)
The Clojure alternative (simpler): https://github.com/yogthos/Selmer/
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by jlongster on Thursday October 24, 2013 @10:02PM (#6609349)
Awesome! A solid templating engine with that syntax makes it a lot easier to move languages and ecosystems. I've been meaning to write more Clojure so it's good to know this exists.
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by elwell on Thursday October 24, 2013 @08:12PM (#6608984)
:O the background sparks are different every pageload.
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by gkoberger on Thursday October 24, 2013 @05:33PM (#6608144)
Very cool, James!
Re:Show HN: Nunjucks – Node templates with inheritance, asyn... by jlongster on Thursday October 24, 2013 @06:45PM (#6608559)
Thanks!