From fe15dec6e29fb6068c2ecfc531e6e3b2591db863 Mon Sep 17 00:00:00 2001 From: noel Date: Thu, 19 Sep 2019 11:00:46 +0200 Subject: [PATCH] Added Support for Twing --- lib/consolidate.js | 24 +++++++++++++++++++++++- package.json | 1 + test/consolidate.js | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/consolidate.js b/lib/consolidate.js index ee3e827..8836da4 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -1761,6 +1761,28 @@ exports.squirrelly.render = function(str, options, cb) { }); }; /** - * expose the instance of the engine - test + * Twing support. + */ + +exports.twing = fromStringRenderer('twing'); + +/** + * Twing string support. + */ + +exports.twing.render = function(str, options, cb) { + return promisify(cb, function(cb) { + var engine = requires.twing || (requires.twing = require('twing')); + try { + let rendTmpl = new engine.TwingEnvironment(new engine.TwingLoaderNull).createTemplate(str).render(options); + let tmpl = cache(options) || cache(options, rendTmpl); + cb(null, tmpl); + } catch (err) { + cb(err); + } + }); +}; +/** + * expose the instance of the engine */ exports.requires = requires; diff --git a/package.json b/package.json index cb34bc0..62c2370 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "tinyliquid": "^0.2.30", "toffee": "^0.1.12", "twig": "^0.10.0", + "twing": "^2.3.5", "underscore": "^1.3.3", "vash": "^0.12.2", "velocityjs": "^0.8.2", diff --git a/test/consolidate.js b/test/consolidate.js index 193f329..b9dad36 100644 --- a/test/consolidate.js +++ b/test/consolidate.js @@ -72,3 +72,4 @@ require('./shared').test('razor'); require('./shared').test('squirrelly'); require('./shared/partials').test('squirrelly'); require('./shared/helpers').test('squirrelly'); +require('./shared').test('twing'); \ No newline at end of file