Skip to content

Commit

Permalink
Merge pull request #327 from noelelias/master
Browse files Browse the repository at this point in the history
Added Support for Twing
  • Loading branch information
doowb committed Nov 2, 2019
2 parents b65a14d + 31b7329 commit 31cfe78
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,31 @@ exports.squirrelly.render = function(str, options, cb) {
}
});
};
/**
* 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 {
new engine.TwingEnvironment(new engine.TwingLoaderNull()).createTemplate(str).then((twingTemplate) => {
twingTemplate.render(options).then((rendTmpl) => {
var tmpl = cache(options) || cache(options, rendTmpl);
cb(null, tmpl);
});
});
} catch (err) {
cb(err);
}
});
};
/**
* expose the instance of the engine
*/
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"razor-tmpl": "^1.3.1",
"react": "^15.6.2",
"react-dom": "^15.3.2",
"semver": "^6.3.0",
"should": "*",
"slm": "^0.5.0",
"squirrelly": "^5.0.1",
Expand All @@ -78,6 +79,7 @@
"tinyliquid": "^0.2.30",
"toffee": "^0.1.12",
"twig": "^0.10.0",
"twing": "^4.0.0",
"underscore": "^1.3.3",
"vash": "^0.12.2",
"velocityjs": "^0.8.2",
Expand Down
4 changes: 4 additions & 0 deletions test/consolidate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var cons = require('../');
var semver = require('semver');
/*eslint-env node*/
/*eslint quotes: [2, "single"] */
require('./shared').test('jade');
Expand Down Expand Up @@ -72,3 +73,6 @@ require('./shared').test('razor');
require('./shared').test('squirrelly');
require('./shared/partials').test('squirrelly');
require('./shared/helpers').test('squirrelly');
if (semver.satisfies(process.version, '>=8.0.0')) {
require('./shared').test('twing');
}
1 change: 1 addition & 0 deletions test/fixtures/twing/user.twing
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>{{ user.name }}</p>

0 comments on commit 31cfe78

Please sign in to comment.