Added plates support #89

wants to merge 9 commits into


None yet
4 participants

No description provided.

study and others added some commits Jan 24, 2013

@ForbesLindesay ForbesLindesay commented on an outdated diff Jan 25, 2013

+* Plates Support.
+exports.plates = fromStringRenderer('plates');
+* Plates string support.
+exports.plates.render = function(str, options, fn) {
+ var engine = requires.plates || (requires.plates = require('plates'))
+ , map = || undefined;
+ try {
+ var tmpl = cache(options) || cache(options, engine.bind(str, options, map));

ForbesLindesay Jan 25, 2013


This caches too much, you can't use caching with it, if you pass the options when you do caching then dynamic sites won't work. consolidate will automatically cache the string so you just need:

var tmpl = engine.bind(str, options, map);

@tj tj and 1 other commented on an outdated diff Jan 29, 2013

@@ -67,6 +68,20 @@ cons[name]('views/page.html', { user: 'tobi' }, function(err, html){
+### Example using [Plates](
+Plates accepts an optional third argument, a mapping object. To pass a map object through consolidate add it to
+var cons = require('consolidate')
+ , _map = require('plates').Map();
+_map.class('list').append('views/partial.html', {item: ['one', 'two']});
+cons.plates('views/user.html', {user: 'Tobi', map: _map}, function(err, html) {
+ if (err) throw err;
+ console.log(html);

tj Jan 29, 2013


i dont think we should even bother with specific examples, if it cant fit the consolidate model it shouldn't be in the lib


ForbesLindesay Jan 29, 2013


I agree, for cases like this people can read the source to work out how to pass the map option to plates.

@BridgeAR BridgeAR commented on the diff Jan 21, 2016

@@ -18,7 +18,7 @@ exports.test = function(name) {
var locals = { user: user };
cons[name](path, locals, function(err, html){
if (err) return done(err);
- html.should.equal('<p>Tobi</p>');
+ html.should.match(/Tobi/);

BridgeAR Jan 21, 2016


Does the <p>...</p> really has to be removed? I guess using match with the p should still be possible? And if the id is going to be kept, you might aswell add that as optional part in the regex to match that too.


BridgeAR commented Jan 21, 2016

Please rebase and squash your commits. Otherwise, besides my comment, it's LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment