Permalink
Browse files

Merge pull request #3 from jafl/options.layout

allow relative path to layout passed as config
  • Loading branch information...
2 parents 3ebb84d + 4d4635c commit 2b89908c04120dfc836236bcced2436ae90a416e @mgutz mgutz committed Nov 8, 2012
Showing with 6 additions and 4 deletions.
  1. +2 −2 README.md
  2. +4 −2 lib/hbs.js
View
@@ -22,8 +22,8 @@ Options for `#express3`
hbs.express3({
defaultLayout: "{String} [Optional] Absolute path to default layout template",
extname: "{String} Extension for templates, defaults to `.hbs`",
- handlebars: "{Module} Use external handlebars instead of express-hbs dependency"
- partialsDir: "{String} Path to partials templates",
+ handlebars: "{Module} Use external handlebars instead of express-hbs dependency",
+ partialsDir: "{String} Path to partials templates"
});
Partials may use any extension, which is better for syntax highlighting.
View
@@ -243,8 +243,10 @@ var _express3 = function(filename, options, cb) {
parseLayout(str, filename, function(err, layoutTemplate) {
if (err) return cb(err);
- // If no layout try using default
- if (!layoutTemplate && defaultLayoutTemplate)
+ // If no layout, try using options config or default
+ if (!layoutTemplate && options.layout)
+ layoutTemplate = path.resolve(path.join(path.dirname(filename), options.layout));
+ else if (!layoutTemplate && defaultLayoutTemplate)
layoutTemplate = defaultLayoutTemplate;
if (layoutTemplate && options.cache) {

0 comments on commit 2b89908

Please sign in to comment.