Questions tagged [nunjucks]

A rich and powerful templating language for JavaScript

Nunjucks is a port of jinja2.

Tag questions with Nunjucks if you have issues with any of the following functionalities in the templates:

  • Variables
  • Filters
  • Template Inheritance
  • Tags if for asyncEach1 asyncAll macro set extends block include import raw
  • Keyword Arguments
  • Comments
  • Whitespace Control
  • Expressions Math Comparisons Logic`` If Expression Function Calls`
  • Autoescaping
  • Global Functions range([start], stop, [step]) cycler(item1, item2, ...itemN) joiner([separator])
  • Builtin Filters

official website

510 questions
9
votes
3 answers

Eleventy (11ty) Data Pagination - Title from data

Trying to setup pagination with data, where {{ title }} in {{ title }} is the title of the current page as defined in projects.json Assumed this could be done: # main.njk {{ title }} #…
9
votes
4 answers

Cannot get index of item in array with Nunjucks for loop

I'm having some trouble getting indexes of a items in an array from a Nunjucks {% for %} loop. The array I am targeting is simple and looks like this pages[1,2,3] And this is the Nunjucks loop {% for i,p in data.tickets.pages %} {{ i }} : {{ p…
mikeym
  • 5,705
  • 8
  • 42
  • 62
9
votes
5 answers

Using Nunjucks with Express 4

I am trying to use Nunjucks as a template engine from Express. I did this: var express = require('express'); var nunjucks = require('nunjucks'); var path = require('path'); var bodyParser = require('body-parser'); var load =…
user007
  • 3,203
  • 13
  • 46
  • 77
8
votes
1 answer

How to safely render JSON into an inline