rotundasoftware / nunjucksify

Everything you expect from a module named nunjucksify and more.
34 stars 10 forks source link

nunjucks.Environment is not a constructor #17

Closed kluplau closed 7 years ago

kluplau commented 8 years ago

Hi guys,

Trying to render a template with data in run-time, but i get an error in the browser:

nunjucks.Environment is not a constructor

The file that has the error is also called test.njk (same name as my template) but I guess that it's rendered. It's on line 2:

var env = nunjucks.env || new nunjucks.Environment();

This is my setup:

gulpfile.js

...
    var bundler = browserify(file, { debug: true });

    bundler.transform(nunjucksify, {
        extension: '.njk'
    });
...

main.js

var $ = require('jquery'),
    test = require( './templates/components/test.njk');

$(function(){
    $("body").append(test.render({
        name : 'Kenneth'
    }));
});

test.njk

<div>
    Hi {{ name }} what's up?
</div>
kluplau commented 8 years ago

Oh, downgraded to version ~1.3.4 instead of latest ^2.4.2 and it worked. Have you stopped development on this project?

dgbeck commented 8 years ago

Hi @Blueblau ,

please see https://github.com/rotundasoftware/nunjucksify/issues/16

We are waiting on a fix in nunjucks to be published before publishing the new version.

going to leave this issue open in hopes other people running into this problem will see it.

dgbeck commented 7 years ago

fixed in just published v2.0.0, which bumps nunjucks dependency to 3.0.0 thx!