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
0
votes
0 answers

Javascript: Variable declaration in node.js HTML file

Node.js: I am iterating through the contents of title2 using for loop. But to make the div tag unique, I am using the {{var i=0;}} it gives the following error expected variable end. I also tried {% var i = 0; %} but that too doesnt seem to work I…
0
votes
1 answer

Render precompilled nunjucks (browserify+nunjucksify) with ampersand-view

Trying to render browserify+nunjucksify-ed precompiled templates in a an ampersand-view. This works as expectd: var tpl = require('app1/template-1.nunj'); console.log(tpl.render({name: 'flemming', isDancing: 'perhaps'})) This does not: var MainView…
Gnimmelf
  • 137
  • 2
  • 9
0
votes
1 answer

Metatemplating in Nunjucks

I'm working on a Marionette app that has certain repeating UI patterns in Nunjucks, for example:
rajadain
  • 21
  • 5
0
votes
1 answer

Include content of a URL in html file

I'm building an app with Node.JS and Express v4. My template engine is Nunjucks. I've rendered a (widget) route (using Express): app.get( '/widget' , routes.widget);. So I can go to the url http:localhost:9999/widget and the widget works and loads…
Baumannzone
  • 760
  • 2
  • 19
  • 38
0
votes
2 answers

Node JS Template Add Object To Window

I was wondering if there was a way, when rendering a javascript template with Node, to attach an object or values to the window object. For example, if I wanted to take the data that was passed to the res.render function and attach it to the window…
Max Baldwin
  • 3,404
  • 3
  • 26
  • 40
0
votes
1 answer

How do you load a Nunjucks template async (client-side)?

From what I see in the docs, when you use the render api and pass a third argument for a callback, calls to render should be async, not sync, yet when I do this client-side: nunjucks.render("template.html", data, function(err, res) { …
Raymond Camden
  • 10,661
  • 3
  • 34
  • 68
0
votes
2 answers

Linking assets in express js depending on environment

Is there a way of linking assets in my html files (to be precise: nunjucks files in my case) depending on the environment? I want to include several partial *.css or *.js files in the dev env in order to debug it easier and one concatanated…
jalooc
  • 1,169
  • 13
  • 23
-1
votes
1 answer

Nunjucks if range condition not working, how can I fix this code?

I have the following code but cannot think why it is not working. I want to capture a user's input range. So in this example, if a user enters an input in-between 1 and 2000 it should go to page1 otherwise it should go to page…
Adam
  • 1,439
  • 8
  • 29
  • 47
-1
votes
1 answer

How to dynamically iterate tags attribute with Nunjucks

Let's say I have a desc.json file that looks as following: {"descr": [ { "class":"foo1", "name":"bar1", "pattern": "^[ 0-9]+$" }, { "class": "foo2", "name": "bar2" } ] } and data.json file that…
-1
votes
1 answer

nunjucks not outputting all data from MongoDB

I am using node.js as a scripting language and I am also using nunjucks as the template engine. I have a weird situation going where some of the data that I retrieve from the MongoDB database is not being printed into document. As you see hear these…
black_yurizan
  • 407
  • 2
  • 7
  • 19
-1
votes
1 answer

Express not rendering Nunjucks properly

I am not sure if this is an issue with express or wether I am doing something wrong with nunjucks. I want to create a template hierarchy where template contains all the commons parts and specific pages extend template. For some reason the body field…
-1
votes
1 answer

Include in nunjucks (grunt-nunjucks-2-html) are based on an incorrect path

I'm using Nunjucks with grunt/node via the grunt plugin grunt-nunjucks-2-html My root path is where the gruntfile is, so it's look like this: ./src index.html expo.html ./inc head.html header.html My gruntfile config…
romuleald
  • 1,406
  • 16
  • 31
-2
votes
2 answers

Fetch Data Asynchronously Data Synchronously with JavaScript

I want to fetch data and have it ready for another function to use as a javaScript object. The problem is that the data is fetched after the program completes. Here is the link to the project:…
mchavezi
  • 482
  • 1
  • 4
  • 14
-3
votes
2 answers

Active font-weight with JS + CSS

I need to know how to activate font-weight on the page (I'm using JavaScript). Example: If I'm on the teachers page, the Teachers font-weight should be bold like shown in image below. {% block head…
-4
votes
1 answer

Angular two way binding not working same way as plunker

Angular view(template) is not updating but scopes are up to date when looking on batarang this when coded to be served on express. After creating the same code on Plunker http://plnkr.co/edit/gHTFVkyDBIoJTvNMOgeB?p=preview where works really well…
carlitux
  • 1,217
  • 10
  • 14
1 2 3
33
34