Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto file extension lookup with multiple view engines #3485

Open
svenyonson opened this issue Nov 21, 2017 · 2 comments
Open

Auto file extension lookup with multiple view engines #3485

svenyonson opened this issue Nov 21, 2017 · 2 comments

Comments

@svenyonson
Copy link

@svenyonson svenyonson commented Nov 21, 2017

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:

app.engine('html', cons.underscore);
app.engine('pug', require('pug').__express);

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

@Chopinsky
Copy link

@Chopinsky Chopinsky commented 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.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.

@svenyonson
Copy link
Author

@svenyonson svenyonson commented Nov 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.