expressjs / expressjs/express

Auto file extension lookup with multiple view engines

Open
#3,485 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.