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
1 answer

pg-generator nunjucks unnecessary spaces are inserted and html is breaking

I am trying to generate some react html but strange spaces are inserted breaking the html. Please help!!!! using the base template running with command pgen exec pg-generator-templates/react-crud-template/ -d convectorFeathersServer -u postgres -p…
fedevela
  • 41
  • 1
  • 6
0
votes
1 answer

Nunjucks rendering file paths relative to route being called and overriding express.static setting

Using Nunjucks with Node Trying to figure out a graceful solution to the following problem. With a directory tree sorda like…
dima
  • 870
  • 8
  • 10
0
votes
1 answer

nunjucks for loop and kebob-case

Using nunjucks on Node Have a for loop that iterates over an array without any problems if I use snake_case {% for item in items.micro_release %}
  • {{ item.id }}
  • {% else %}
  • No items found...
  • {% endfor %} As soon as I…
    dima
    • 870
    • 8
    • 10
    0
    votes
    0 answers

    How to pass "css properties" with html templating system

    I'm building a component library with nunjucks and some times I need to pass varialbes to change for example a background image, nunjucks doesn't parse css files and I ended up setting inline styles like so: Includes the component and pass the…
    Francis Vega
    • 152
    • 1
    • 2
    • 10
    0
    votes
    1 answer

    Mustache-like language with knockout-observables

    I am trying to use a Knockout-style view-model with a mustache-like language. So the view model looks something like this: var viewModel = { aValue: ko.observable("boot") } The rather common problem with mustache-like languages is that they do…
    Brian M. Hunt
    • 81,008
    • 74
    • 230
    • 343
    0
    votes
    1 answer

    nunjuncks not rendering because of Content-Security-Policy

    The error: Uncaught Template render error: (result.html) EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src *". The nginx…
    kev
    • 8,928
    • 14
    • 61
    • 103
    0
    votes
    1 answer

    How to use content with HTML inside JSON data with nunjucks and gulp-data?

    how to use HTML with JSON with Gulp-data ? I'm using it in a static website building process with Gulp, Nunjucks and MJML JSON { message:"Welcome to world" } .nunjucks file {{ message }} is giving this output in final…
    Jitendra Vyas
    • 148,487
    • 229
    • 573
    • 852
    0
    votes
    1 answer

    Basic templating with nunjucks

    I'm writing a shell script, and would like to use template it, by keeping my variables in a json file. I'm a beginner to javascript, and so can't seem to get the hang of how to use nunjucks to render my templates. Can you please help me get this…
    lip
    • 114
    • 1
    • 11
    0
    votes
    1 answer

    How can I fill my template with default data in nunjucks and express.js

    I'm using nunjucks as my template engine in an express application. I'm searching for a good way to populate the template with data about state of login. I don't want to put it in the template at every function call i make. I have following…
    stubiklaus
    • 151
    • 8
    0
    votes
    1 answer

    import template with context doesn't seem to be working

    I've recently been trying to get to grips with nunjucks, I've used handlebars before so the learning curve hasn't been that bad. However there is one thing I can't seem to get working: I've got a JSON file which has the following data in…
    Alex Foxleigh
    • 1,784
    • 2
    • 21
    • 47
    0
    votes
    1 answer

    Using watch with Nunjucks on Hapi

    So I've tried both the Nunjucks example in the Vision docs as well as the plugin nunjucks-hapi with the same result - watch does not work. var viewPath = Path.join(__dirname, 'views') var env = NunjucksHapi.configure(viewPath, { watch:…
    cyberwombat
    • 38,105
    • 35
    • 175
    • 251
    0
    votes
    1 answer

    It's possible to use Environment functions in gulp-nunjucks-render?

    I want to use something like Nunjucks render, but with another function. For example addglobal. Is it possible?
    Emanuel Saramago
    • 462
    • 4
    • 16
    0
    votes
    2 answers

    Accessing array sent by server side js in the client js

    I am learning expressjs,mongodb using nunjucks template.An array is sent from server to html in the following way: poll.find().sort({'date': -1}).toArray(function(err,docs){ res.render("home",{polls:docs}); }); The variable polls is an…
    R-R
    • 317
    • 1
    • 6
    • 18
    0
    votes
    1 answer

    Template Render Error : Expect Block End in Enblock

    Nunjucks throws this error when I am restarting GULP. I cannot see what the problem might be. Unfortunately Nunjucks does not give me the file or tag where this is happening. events.js:141 throw er; // Unhandled 'error' event ^ Template…
    Oliver Watkins
    • 12,575
    • 33
    • 119
    • 225
    0
    votes
    3 answers

    Sails.js, Nunjucks & LiveReload

    I've managed to get Nunjucks working with Sails.js, however it seems that the changes are not being picked up until I restart the server. I'll automatically see the changes reflected once or twice, but after that, even manually refreshing the…
    Niall O'Brien
    • 182
    • 1
    • 1
    • 9
    1 2 3
    33
    34