Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAuto file extension lookup with multiple view engines #3485
Comments
|
I think the biggest issue of supporting multiple view engines would be the ambiguity of rendering views of the same file name: say, if we have |
|
One method would be the order that defaults are declared using set view engine:
- app.set('view engine', 'html');
- app.set('view engine', ['html','pug']);
Another would be the order that the engines are added:
- app.engine('html', cons.underscore);
- app.engine('pug', require('pug').__express);
Or, it could be that the developer is responsible for view name uniqueness.
… On Nov 21, 2017, at 5:10 PM, Jacob Zuo ***@***.***> wrote:
I think the biggest issue of supporting multiple view engine would be ambiguity of rendering views of the same file name: say if we have home.ejs and home.pug in the same folder, the render engine won't be sure which one of these should be the one to render.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#3485 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAWlLlAav1orGu_ZG0tQCheVhvLEVjL-ks5s42ZjgaJpZM4QmQH4>.
|
It is possible to select a default view extension with
app.set('view engine', 'html');. This is fine when you only use one view engine - you can only set this once. But if I then add a second view engine, I must specify the file extension when calling render on these views. Express should be smart enough to lookup the view name with all of the registered view engines:This should suffice for both registering the view engines and adding to the list of extensions to search for when referencing a view name without an extension