Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support for Twing #327

Merged
merged 13 commits into from
Nov 2, 2019
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>