You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto file extension lookup with multiple view engines #3485
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
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 home.ejs and home.pug under the same folder, the engine won't be sure which one of these should be the one requested to render.
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.
Activity
Chopinsky commentedon Nov 22, 2017
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
home.ejsandhome.pugunder the same folder, the engine won't be sure which one of these should be the one requested to render.svenyonson commentedon Nov 22, 2017