Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a common convention for template extensions when using Nunjucks?

Tags:

nunjucks

When working with Nunjucks templates which requite rendering or compilation is there a standard naming convention to be used to have them processed? i.e. file.nunjucks, file.nunjucks.html, or file.njs etc.

I know that when working with other template languages it's common to use their name as the extension such as file.liquid, file.ejs, etc, but I've not seen much in reference to Nunjucks.

like image 989
ianyoung Avatar asked Oct 11 '14 14:10

ianyoung


People also ask

What is Nunjucks template?

Nunjucks is a full featured templating engine for javascript. It is heavily inspired by jinja2. View the docs here.

How does Nunjucks pass data?

You can use gulp-data which allows you to pass json files to the task runner you're using to render Nunjucks.


1 Answers

I personally prefer the extension '.njk', its also something that they have as an example on the Nunjucks docs.

File Extensions

Although you are free to use any file extension you wish for your Nunjucks template files, the Nunjucks community has adopted .njk.

If you are developing tools or editor syntax helpers for Nunjucks, please include recognition of the .njk extension.

like image 74
t. Macleod Sawyer Avatar answered Oct 18 '22 22:10

t. Macleod Sawyer