From fb44bc69f4899dd45338309302b604923f924d7f Mon Sep 17 00:00:00 2001 From: Eric Schmitt Date: Fri, 17 Aug 2012 05:08:19 -0700 Subject: [PATCH] [just] [test] [dist] Add just engine plugin and associated test for async render(), Add just template engine to devDependencies --- lib/engines/just/index.js | 21 +++++++++++++++++++++ package.json | 1 + test/viewful-engines-test.js | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 lib/engines/just/index.js diff --git a/lib/engines/just/index.js b/lib/engines/just/index.js new file mode 100644 index 0000000..8a30c69 --- /dev/null +++ b/lib/engines/just/index.js @@ -0,0 +1,21 @@ +/** + * Just Support + */ + +exports.attach = function (options) { + var Just = require ('just'), + options = options || {}; + this.just = { + render: function (view, data, cb) { + var engine; + options.root = {}; + options.root.page = view.template; + engine = new Just(options); + try { + engine.render('page', data, cb); + } catch (err) { + cb(err); + } + } + }; +}; diff --git a/package.json b/package.json index e8ec47c..11c9770 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "hogan.js": "*", "jazz": "*", "jqtpl": "*", + "just": "*", "mustache": "*", "qejs": "*", "underscore": "*", diff --git a/test/viewful-engines-test.js b/test/viewful-engines-test.js index 6c52268..1f88d1c 100644 --- a/test/viewful-engines-test.js +++ b/test/viewful-engines-test.js @@ -176,6 +176,14 @@ vows.describe('viewful-engines-test').addBatch({ }), 'and calling View.render(user)': helpers.renderSync(user, "

tobi

"), 'and calling View.render(user, cb)': helpers.render(user, "

tobi

") + }, + + 'a new viewful.View({ input: "just" })': { + topic: new viewful.View({ + template: "

<%= user.name %>

", + input: "just" + }), + 'and calling View.render(user, cb)': helpers.render(user, "

tobi

") } }