You are viewing...

Shoutout to Mozilla for Nunjucks

Updated on November 30, 2019 at the 17th hour
Posted under:

DISCLAIMER: All views are considered my own and you should not draw any conclusions on associates.

Mozilla maintains Nunjucks (https://mozilla.github.io/nunjucks/), a templating library written in Javascript. Apparently drew its inspiration from Jinja, which is a really good templating lib in Python.

I was looking for a templating library, written in Javascript, that supported conditional statements and inline importing files. Handlebars and co. do not, from what I saw, support inline imports as you have to register "partials" in code which is not ideal. Look, when writing code generation software the template files can get quite big and yuck with all the control statements and blocks. I wanted a way to split the files into manageable chunks and Nunjucks delivers.

You can even precompile your templates if you wanted performance. It is targeted for html templates though.

A bonus is that you can define macros, which I use to split up common pieces such as function argument formats or partial SQL statements.

So far, I really happy with this choice of templating library combined with a prettify library.

You just read "Shoutout to Mozilla for Nunjucks". Please share if you liked it!
You can read more recent posts here.