Questions tagged [gulp-nunjucks-render]

Nunjucks is a rich and powerful templating language for JavaScript. gulp-nunjucks-render is a gulp plugin which renders Nunjucks templates. Use this tag for questions regarding rendering nunjucks templates with gulp, using the gulp-nunjucks-render plugin.

gulp-nunjucks-render
Filter by
Sorted by
Tagged with
0 votes
1 answer
41 views

How to automate functional programing, and avoid repeating myself

Within my gulpfile.js I have the following two functions that are making use of rendering gulp-nun-jucks for 2 different views... function genNunJucks(cb) { return src(paths.views.src) ....
klewis's user avatar
  • 7,924
0 votes
0 answers
72 views

NodeJS Express Nunjucks: Error: template not found: frontend/home.html at createTemplate

Error: template not found: frontend/home.html at createTemplate (/var/www/apps/moss/crash-game/node_modules/nunjucks/src/environment.js:290:15) at next (/var/www/apps/moss/crash-game/node_modules/...
asega's user avatar
  • 43
0 votes
1 answer
62 views

How to wrap HTML to If Expression statements in Nunjucks

Based on the following docs, I can easily make use of the If Expressions as exampled. But how can we take them further by wrapping HTML to the object? I want to do something like this... {{ "<...
klewis's user avatar
  • 7,924
0 votes
1 answer
208 views

How to properly return an associative array back to a nunjucks template

Within my gulp nunjucks area, I created a custom filter that generates date & time information for the week. I'm stuck in knowing how to return an associative array back into my nunjucks template ...
klewis's user avatar
  • 7,924
1 vote
0 answers
180 views

gulp fails to include files on case sensitive file systems

I'm trying to run a project on Ubuntu, which uses Nunjucks, and the gulp-nunjucks-render plugin is used to render the Nunjucks templates. The developers were mainly using this project on Windows and ...
Renaud is Not Bill Gates's user avatar
0 votes
1 answer
48 views

Gulp Loop Renders locale tag Incorrectly in Nunjucks Template

I've created a gulp task to generate four pages based on the same template, for different languages / locales. The locales are: en-US, en-CA, en-NZ and en-AU. Previously, it was just a simple task ...
cslem's user avatar
  • 51
0 votes
1 answer
429 views

How to render a global variable as data inside for loop in the nunjucks?

I faced with a problem: I have global variables with SVG icons and I want to render all icons inside template using for loop. How to render a global variable as data inside for loop. facebook: <...
Av0me's user avatar
  • 3
1 vote
1 answer
905 views

Passing current file name in to the nunjuck template

is there some possibility to pass current folder name in to the nunjuck template? Something like: This folder name is {{currentFolderName}} Output: This folder name is navigation from path for ...
Michal Šimkovič's user avatar
0 votes
1 answer
822 views

Gulp 4 - How to generate dynamic tasks based on two arrays

I'm building an e-mail generation pipeline (multiple templates) using nunjucks and json translation files. This means I need to loop over the multiple templates and the translation files, however I ...
elDrimm's user avatar
  • 106
0 votes
1 answer
2k views

How to setup the baseurl for nunjucks

I want to deploy the site to different servers for testing, production etc. So defining a basepath by changing one variable or setting would be the prefered method. What is the best method to ...
Lasithds's user avatar
  • 2,221
2 votes
3 answers
3k views

Dynamic title and description in the Nunjucks template engine

I'm trying to understand the language of Nunjucks templates. To generate HTML I use Gulp + plugin gulp-nunjucks-render. Faced a problem: I can not understand how to implement the generation of meta ...
Yuri Fedorov's user avatar
0 votes
3 answers
700 views

How can i multiply data in nunjuncks?

for instance <div class="price">{{blocks.quantity}} x {{blocks.price}} </div> i want to multiply price by quantity data from Json file.
Bravis's user avatar
  • 91
1 vote
3 answers
588 views

How to use nunjucks groupby with different value?

i can`t figure out how can i gropBy my data from Json when i have this kind of values 2017-10-16 12:07:07 2017-10-16 12:07:07 2017-10-16 15:09:08 2017-10-16 15:09:08 2017-10-16 15:09:08 2017-10-...
Gosha Travin's user avatar
1 vote
1 answer
5k views

How to add nunjucks-date-filter?

I can't understand where should i put all this code , https://github.com/e-picas/nunjucks-date-filter i have this structure enter image description here this is my template <div class="...
Gosha Travin's user avatar
4 votes
3 answers
4k views

Get current URL in Nunjucks template?

Seems like it should be pretty straightforward, but I'm having a really hard time finding an answer. How do you find the current page's URL within a Nunjucks template? Something like this would be ...
saricden's user avatar
  • 2,234
0 votes
1 answer
3k views

How to set macro variable in the page template for Nunjucks

I am using Nunjucks to set up a complicated site. My folder structure is as such: frontend/ |- dev/ |- gulpfile.js |- css/ |- images/ |- js/ |- pages/ |- dashboard....
Cienwen's user avatar
  • 107
0 votes
1 answer
660 views

gulp-nunjucks-render is taking a lot of time to compile

I am using gulp-nunjucks-render for HTML templating. The problem is, it is taking more than 3-4 minutes to compile. Even though I have only seven nunjucks templates. 'use strict'; var gulp = ...
Ajay Rawat's user avatar
4 votes
0 answers
579 views

Detect changes between multiple source files using Gulp

The original issue I was having was that the task was running x amount of times for the number of files existing inside src.pages, I fixed this by adding the 'changed-in-place' plugin, to compare the ...
Luke's user avatar
  • 205
1 vote
1 answer
1k views

Looping over json, gulp-nunjucks-render rendering all files with same content

I'm trying to render 30+ html pages with gulp-nunjucks-render. I have created one nunjucks template and two json files (general template parts for header and footer and an array of posts data). The ...
Kaur Saarepuu's user avatar
1 vote
1 answer
2k views

Multiple Nunjucks files with different JSON data using gulp

I would like to use gulp and Nunjucks to generate multiple template files at once with varying content. These templates will all have the exact same layout, but pass in different variables for text/...
Morgan's user avatar
  • 584
0 votes
0 answers
795 views

Add key-value pair in exiting json object in nunjucks

I want to add a new key-value pair in JSON object with nunjucks template, but unable to add it(don't want to add any custom filter). suppose I have an object var obj = {"id": "1", "name": "test", "...
Vikas Sharma's user avatar
0 votes
1 answer
468 views

Delete a json key-vaue in nunjucks variable

I am stuck at a point where I want to delete a key-value pair from json object in nunjucks template variable. I have an object: var json = {"id": "123", "obj": {"id": "456", "name": "testing"}, "name"...
Vikas Sharma's user avatar
0 votes
1 answer
904 views

gulp-nunjucks-render and adding data from single file

How can I include data to gulp-nunjucks template from separate file? //template/data/data.html {% set list = [ { title: 'Item1' }, { title: 'Item2' } ] %} This ...
Skif's user avatar
  • 1,208
1 vote
3 answers
3k views

Nunjucks dynamic page template

i'm using nunjucks (gulp) as templating language and i want to build a dynamic page template. This is my Json: "pages": [ { uname: "Welcome", title: "Page 1 Headline" }, {...
Ingo Köpp's user avatar
0 votes
1 answer
973 views

Can Nunjucks output files in multiple languages

I'm trying to create a multi language page, I was hoping to use different json files for different languages and have gulp output the files with a language suffix in the file name. So far I've loaded ...
Ioan-Radu Tanasescu's user avatar
0 votes
2 answers
287 views

Render value to tenths place in nunjucks template?

Using the round() filter I can achieve the correct precision to the tenths place as in {{ value | round(1) }} however I still want to display the tenths place if value is zero or a whole integer. (0....
Don's user avatar
  • 4,046
1 vote
1 answer
1k views

Check for NaN in nunjucks template?

I'm trying to display 'n/a' instead of NaN in a popup. Something like: {% if value == NaN %} n/a {% endif %} I realize I can always catch it earlier on before the template is ...
Don's user avatar
  • 4,046
0 votes
1 answer
1k views

JSON data in nunjucks templating, using gulp-data

I would like to use JSON data inside of nunjucks "set". A minimal example: index.html {% set divname='foo' %} {% include 'template.nunjucks' %} template.nunjucks <div class="{{divname}}"><...
KayakinKoder's user avatar
  • 3,343
0 votes
1 answer
1k views

gulp-nunjucks-render include paths

I have a project set up like this: and I'm using gulp-nunjucks-render for templating. My gulpfile.js looks like this: gulp.task('nunjucks', function() { // Gets .html and .nunjucks files in ...
Meek's user avatar
  • 3,188
1 vote
0 answers
290 views

Rendering a template using Gulp, Nunjucks, and an Array

I have some html like this: <code class="html"> <div class="u-color-background-gray-100"> <code>u-color-background-gray-100</code> </div> <...
Ole's user avatar
  • 44.4k