Skip to content

Commit

Permalink
Partials Underscore Compile
Browse files Browse the repository at this point in the history
Made a small modification to the underscore support render method to allow the template partials to get compiled allowing data to get passed to those as well. 

var user = {username: 'Beetlejuice'};
<%= partials.xanadu(user) %>
  • Loading branch information
jaysonpotter authored Mar 16, 2018
1 parent e7acbf2 commit dda9fdd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/consolidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit dda9fdd

Please sign in to comment.