ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

Each partials dir can be namespaced (with Promises) #70

Closed joanniclaborde closed 10 years ago

joanniclaborde commented 10 years ago

(this is a rewrite of https://github.com/ericf/express3-handlebars/pull/64, based on https://github.com/ericf/express3-handlebars/tree/promises)

As stated in #20, having multiple partialsDir can introduce naming collisions. This pull request adds support for partials namespaces. Each partialsDir can optionally be specified as an object, with a dir and namespace properties. Example:

var partialsDir = [
  'local/views',
  {dir: '/otherPackage/shared/views', namespace: 'otherPackage'}
];
...
app.engine('handlebars', exphbs({partialsDir: partialsDir}));

If both local/views and /otherPackage/shared/views contain a template named status.hbs, they can be included like this in a view:

{{> status}}
{{> otherPackage/status}}
ericf commented 10 years ago

Thanks! I merged this in.

joanniclaborde commented 10 years ago

Thanks Eric!