expressjs / expressjs/express

Add "set" Method to "Router"

Open
#2,524 6 comments 0 reactions 0 assignees View on GitHub
discuss ideas module:router
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

Hey guys,
I think it would be nice to be able to set options to single Routes. For example one can set a default layout for the handlebars rendering engine with

``` javascript
app.set('view options', { layout: 'main' });
```

or with

``` javascript
app.engine(".hbs", handlebars({
defaultLayout: "main",
}));
```

When using a `express.Router()` for example with `app.use("/admin", adminRouter)` it would be nice to be able to use something like

``` javascript
adminRouter.set('view options', { layout: 'adminMain' });
```

to prevent using

``` javascript
res.render('home', {layout: "adminMain"});
```

for every call to `res.render`

Thanks

-André-

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.