Skip to content

tmpl.render is not a function #21

Description

@bjunc

The code below throws the error: tmpl.render is not a function(…)

helloworld.nunj

Hello {{ person }}

app.js

var tmpl = require("./helloworld.nunj");

console.log("HelloWorld tmpl:", tmpl);
tmpl.render({person:"World"});

The output of tmpl is a function that looks like this:

function (ctx, cb) { return nunjucks.render("PATH_TO_NUNJ_FILE", ctx, cb); }

I can actually get the template to render, by treating it as a function:

var tmpl = require("./helloworld.nunj");
tmpl({person:"World"});

However, if I don't use nunjucksify, I can get the expected result:

var nunjucks = require('nunjucks');

var tmpl2 = new nunjucks.Template('Hello {{ person }}');
tmpl2.render({person:"World"});

Any thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions