Skip to content

Conversation

@manuelbieh
Copy link

Following situation:

Appfolder/app.js:

app.engine('html', cons.handlebars);
app.set('views', __dirname + '/views');

[...]
res.render('account/edit', {partials: {
  head: '_head'
}});
[...]

→ Consolidate looks for Appfolder/views/account/_head.html instead of Appfolder/views/_head.html which is the default views folder we defined earlier.

This is in my eyes pretty unfavorable because we don't have a chance to define "default" partials using app.locals() since the folder consolidate is looking for templates differs for every view and depends on the folder the currently compiled template is placed in.

In my version consolidate checks if a default views folder was defined and if so, loads the partials from there instead of from the current path.

app.locals({partials: {head: '_head'}}); then always looks for Appfolder/views/_head.html and ignores the current working dir which makes life much easier.

@doowb
Copy link
Collaborator

doowb commented Sep 17, 2017

I know it's been a long time, but if anyone is still interested in this change, I think it can be useful with the following changes:

  • instead of options.settings.views use options.partialsDir
  • if partial doesn't exist in options.partialsDir fallback to dirname(path) for backwards compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants