Closed rottmann closed 11 years ago
This sounds like an important feature to add, and if I can make a simple change to easily support what you're doing, I'm all for that!
To clarify, are you asking that I should pass the entire app/response locals object (fields
in your example) to the _resolveLayoutPath()
method?
Which would allow the following:
var app = require('express')(),
hbs = require('express3-handlebars').create({ /* ... */ });
app.engine('handlebars', hbs.engine);
hbs._resolveLayoutPath = function (locals) {
var layoutPath = this.constructor.prototype._resolveLayoutPath.apply(this, arguments);
return layoutPath.replace(/%language%/, locals.language);
};
// ...
app.render('foo.handlebars', {language: 'de'});
Yes that will be a great solution. :+1:
@rottmann Okay, this change has been published to npm. Let me know if you run into anything else so we can keep thinking about adding first class multilingual support if the need arises.
My view/layout structure is:
Depending on the users language different layouts and templates will be rendered.
At the moment i extend / overwrite your function
Before render i set de ExpressHandlebars.language variable.
Call render with language Param for the template
Nice will be a param in the fields-param, when the template got rendered and this param will be uses for layouts too.