Skip to content

Commit 6031dfa

Browse files
committed
Merge branch 'master' of https://github.com/dworthen/consolidate.js into dworthen-master
2 parents 7c3a5ea + 4888af3 commit 6031dfa

File tree

7 files changed

+38
-12
lines changed

7 files changed

+38
-12
lines changed

Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [mote](https://github.com/satchmorun/mote) [(website)](http://satchmorun.github.io/mote/)
3333
- [mustache](https://github.com/janl/mustache.js)
3434
- [nunjucks](https://github.com/mozilla/nunjucks) [(website)](https://mozilla.github.io/nunjucks)
35+
- [plates](https://github.com/flatiron/plates)
3536
- [pug (formerly jade)](https://github.com/pugjs/pug) [(website)](http://jade-lang.com/)
3637
- [QEJS](https://github.com/jepso/QEJS)
3738
- [ractive](https://github.com/Rich-Harris/Ractive)

lib/consolidate.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,27 @@ function reactBaseTmpl(data, options){
12611261
return data;
12621262
}
12631263

1264+
/**
1265+
* Plates Support.
1266+
*/
1267+
1268+
exports.plates = fromStringRenderer('plates');
1269+
1270+
/**
1271+
* Plates string support.
1272+
*/
1273+
1274+
exports.plates.render = function(str, options, fn) {
1275+
var engine = requires.plates || (requires.plates = require('plates'))
1276+
, map = options.map || undefined;
1277+
try {
1278+
var tmpl = engine.bind(str, options, map);
1279+
fn(null, tmpl);
1280+
} catch (err) {
1281+
fn(err);
1282+
}
1283+
}
1284+
12641285

12651286

12661287
/**

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"description": "Template engine consolidation library",
44
"version": "0.14.5",
55
"author": "TJ Holowaychuk <[email protected]>",
6+
"license": "MIT",
7+
"main": "index",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/visionmedia/consolidate.js.git"
11+
},
612
"dependencies": {
713
"bluebird": "^3.1.1"
814
},
@@ -40,6 +46,7 @@
4046
"mote": "^0.2.0",
4147
"mustache": "^2.2.1",
4248
"nunjucks": "^3.0.0",
49+
"plates": "~0.4.8",
4350
"pug": "^2.0.0-beta6",
4451
"qejs": "^3.0.5",
4552
"ractive": "^0.8.4",
@@ -62,12 +69,6 @@
6269
"template",
6370
"view"
6471
],
65-
"license": "MIT",
66-
"main": "index",
67-
"repository": {
68-
"type": "git",
69-
"url": "https://github.com/visionmedia/consolidate.js.git"
70-
},
7172
"scripts": {
7273
"test": "mocha"
7374
}

test/consolidate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ require('./shared').test('ect');
3333
require('./shared').test('mote');
3434
require('./shared').test('toffee');
3535
require('./shared').test('atpl');
36+
require('./shared').test('plates');
3637
require('./shared').test('templayed');
3738
require('./shared').test('twig');
3839
require('./shared').test('dot');

test/fixtures/plates/user.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="user"><p id="name"></p></div>

test/fixtures/plates/user.plates

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div id="user"><p id="name"></p></div>

test/shared/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ exports.test = function(name) {
1818
var locals = { user: user };
1919
cons[name](path, locals, function(err, html){
2020
if (err) return done(err);
21-
html.should.equal('<p>Tobi</p>');
21+
html.should.match(/Tobi/);
2222
done();
2323
});
2424
});
@@ -40,10 +40,10 @@ exports.test = function(name) {
4040

4141
cons[name](path, locals, function(err, html){
4242
if (err) return done(err);
43-
html.should.equal('<p>Tobi</p>');
43+
html.should.match(/Tobi/);
4444
cons[name](path, locals, function(err, html){
4545
if (err) return done(err);
46-
html.should.equal('<p>Tobi</p>');
46+
html.should.match(/Tobi/);
4747
calls.should.equal(name === 'atpl' ? 4 : 2);
4848
done();
4949
});
@@ -61,10 +61,10 @@ exports.test = function(name) {
6161
done(new Error('fs.readFile() called with ' + path));
6262
};
6363

64-
html.should.equal('<p>Tobi</p>');
64+
html.should.match(/Tobi/);
6565
cons[name](path, locals, function(err, html){
6666
if (err) return done(err);
67-
html.should.equal('<p>Tobi</p>');
67+
html.should.match(/Tobi/);
6868
done();
6969
});
7070
});
@@ -75,7 +75,7 @@ exports.test = function(name) {
7575
var locals = { user: user };
7676
cons[name].render(str, locals, function(err, html){
7777
if (err) return done(err);
78-
html.should.equal('<p>Tobi</p>');
78+
html.should.match(/Tobi/);
7979
done();
8080
});
8181
});

0 commit comments

Comments
 (0)