Skip to content

Commit fe15dec

Browse files
committed
Added Support for Twing
1 parent ba32aa0 commit fe15dec

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

lib/consolidate.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,28 @@ exports.squirrelly.render = function(str, options, cb) {
17611761
});
17621762
};
17631763
/**
1764-
* expose the instance of the engine - test
1764+
* Twing support.
1765+
*/
1766+
1767+
exports.twing = fromStringRenderer('twing');
1768+
1769+
/**
1770+
* Twing string support.
1771+
*/
1772+
1773+
exports.twing.render = function(str, options, cb) {
1774+
return promisify(cb, function(cb) {
1775+
var engine = requires.twing || (requires.twing = require('twing'));
1776+
try {
1777+
let rendTmpl = new engine.TwingEnvironment(new engine.TwingLoaderNull).createTemplate(str).render(options);
1778+
let tmpl = cache(options) || cache(options, rendTmpl);
1779+
cb(null, tmpl);
1780+
} catch (err) {
1781+
cb(err);
1782+
}
1783+
});
1784+
};
1785+
/**
1786+
* expose the instance of the engine
17651787
*/
17661788
exports.requires = requires;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"tinyliquid": "^0.2.30",
7979
"toffee": "^0.1.12",
8080
"twig": "^0.10.0",
81+
"twing": "^2.3.5",
8182
"underscore": "^1.3.3",
8283
"vash": "^0.12.2",
8384
"velocityjs": "^0.8.2",

test/consolidate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,4 @@ require('./shared').test('razor');
7272
require('./shared').test('squirrelly');
7373
require('./shared/partials').test('squirrelly');
7474
require('./shared/helpers').test('squirrelly');
75+
require('./shared').test('twing');

0 commit comments

Comments
 (0)