Auto file extension lookup with multiple view engines

Open
#3,485 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
backend

Research direction

Start at the app.engine registration and render lookup paths described in the issue. Trace how registered extensions are stored and how extensionless view names are resolved, then add coverage for the html and pug example; done means both engines can render by name without an explicit extension.

Written by the indexing model from the issue text.

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

Dominant language
JavaScript
Stars
69.7k
Forks
25.6k
Avg merge
2d 9h
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from expressjs/express

All issues in expressjs/express

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.