diff --git a/lib/consolidate.js b/lib/consolidate.js index 37386bf..70612ff 100644 --- a/lib/consolidate.js +++ b/lib/consolidate.js @@ -901,6 +901,9 @@ exports.underscore.render = function(str, options, fn) { return promisify(fn, function(fn) { var engine = requires.underscore || (requires.underscore = require('underscore')); try { + for (var partial in options.partials) { + options.partials[partial] = engine.template(options.partials[partial]); + } var tmpl = cache(options) || cache(options, engine.template(str, null, options)); fn(null, tmpl(options).replace(/\n$/, '')); } catch (err) { diff --git a/test/consolidate.js b/test/consolidate.js index a900f8e..375bacc 100644 --- a/test/consolidate.js +++ b/test/consolidate.js @@ -35,6 +35,7 @@ require('./shared').test('handlebars'); require('./shared/partials').test('handlebars'); require('./shared/helpers').test('handlebars'); require('./shared').test('underscore'); +require('./shared/partials').test('underscore'); require('./shared').test('lodash'); require('./shared').test('qejs'); require('./shared').test('walrus'); diff --git a/test/fixtures/underscore/partials.underscore b/test/fixtures/underscore/partials.underscore new file mode 100644 index 0000000..472c5ae --- /dev/null +++ b/test/fixtures/underscore/partials.underscore @@ -0,0 +1 @@ +

<%- user.name %>

<%= partials.partial(user) %> \ No newline at end of file diff --git a/test/fixtures/underscore/user_partial.underscore b/test/fixtures/underscore/user_partial.underscore new file mode 100644 index 0000000..5e42261 --- /dev/null +++ b/test/fixtures/underscore/user_partial.underscore @@ -0,0 +1 @@ +

<%- name %> from user_partial!

\ No newline at end of file diff --git a/test/shared/partials.js b/test/shared/partials.js index 5982b6c..1ff4e52 100644 --- a/test/shared/partials.js +++ b/test/shared/partials.js @@ -41,8 +41,22 @@ exports.test = function(name) { done(); }); }); - } - else { + } else if (name == 'underscore') { + it('should support partials', function(done){ + var path = 'test/fixtures/' + name + '/partials.' + name; + var locals = { + user: user, + partials: { + partial: 'user_partial' + } + }; + cons[name](path, locals, function(err, html){ + if (err) return done(err); + html.should.equal('

Tobi

Tobi from user_partial!

'); + done(); + }); + }); + } else { it('should support rendering a partial', function(done){ var str = fs.readFileSync('test/fixtures/' + name + '/user_partial.' + name).toString(); var locals = {