Skip to content

Auto file extension lookup with multiple view engines #3485

Open

Description

@svenyonson

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

Activity

  1. Chopinsky commented on Nov 22, 2017

    @Chopinsky

    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.

  2. svenyonson commented on Nov 22, 2017

    @svenyonson
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions