Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use standard express view object as template context

  • Loading branch information...
commit 7a47d1ea644fb6b82782bfe7bbda861daf95126f 1 parent b434711
Glen Mailer glenjamin authored
Showing with 8 additions and 12 deletions.
  1. +3 −5 hogan-express.coffee
  2. +5 −7 hogan-express.js
8 hogan-express.coffee
View
@@ -61,14 +61,12 @@ render = (path, opt, fn) ->
read path, opt, (err, str) ->
return fn(err) if (err)
try
- locals = opt.settings.locals or {}
- locals = locals extends opt._locals
tmpl = hogan.compile(str, opt)
- result = tmpl.render(locals, partials)
+ result = tmpl.render(opt, partials)
if layout
- locals.yield = result
+ opt.yield = result
tmpl = hogan.compile(layout, opt)
- result = tmpl.render(locals, partials)
+ result = tmpl.render(opt, partials)
fn(null, result)
catch err
fn(err)
12 hogan-express.js
View
@@ -107,19 +107,17 @@ render = function(path, opt, fn) {
layout = opt.layout === void 0 ? opt.settings.layout : layout = opt.layout;
return renderLayout(layout, opt, function(err, layout) {
return read(path, opt, function(err, str) {
- var locals, result, tmpl;
+ var result, tmpl;
if (err) {
return fn(err);
}
try {
- locals = opt.settings.locals || {};
- locals = __extends(locals, opt._locals);
tmpl = hogan.compile(str, opt);
- result = tmpl.render(locals, partials);
+ result = tmpl.render(opt, partials);
if (layout) {
- locals["yield"] = result;
+ opt["yield"] = result;
tmpl = hogan.compile(layout, opt);
- result = tmpl.render(locals, partials);
+ result = tmpl.render(opt, partials);
}
return fn(null, result);
} catch (err) {
@@ -130,4 +128,4 @@ render = function(path, opt, fn) {
});
};
-module.exports = render;
+module.exports = render;
Please sign in to comment.
Something went wrong with that request. Please try again.