expressjs / expressjs/express

Feature request View global option ignore extname

Open
#2,708 12 comments 0 reactions 0 assignees View on GitHub
5.x ideas
Dominant language
JavaScript
Stars
69.5k
Forks
25k
Avg merge
4d 20h
Merged PRs (30d)
9

Description

In react-engine you set the `view engine` via a global `app.set` variable.

``` javascript
app.set('view engine', 'js')
```

My request is for another global view option

``` javascript
app.set('view ignore extname', true)
```

Here's why:

In react engine you pass the current page url to `res.render`

```
app.get("/", function(req, res){
return res.render(req.url, data)
})
```

When that url has a period it is picked up by a [rendering engine the as an `extname`](https://github.com/strongloop/express/blob/master/lib/view.js#L57). So for the url `/hello?url=google.com` you get an error because it's looking for the module `com`.

You can enable periods in react-engine simply by commenting out [this line](https://github.com/strongloop/express/blob/master/lib/view.js#L57). I'm putting in a pull request to copy the whole `View` with this line commented but it would be great if express supported it.

Is there a way to do this already?

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.