visionmedia/express — pull request #1577 by caridy (2013-04-11 05:00:04+00:00)
Title: introducing view constructor configuration

User Stories
------------

* As a developer, I want to bend the instantiation process for views so I can optimize it for my product.
* As a developer, I want to render views that are loaded over the network so I can control them thru an editorial tool.
* As a developer, I want to render views that are compiled into javascript so I can improve performance.

Shortcoming
------------

The current implementation:

* enforces the use of a view constructor (`lib/view.js`) that is not exposed, hence cannot be customized, optimized or bended.
* requires the view engine to be bound to the filesystem where each view will have to be backed up by a local file without room for abstraction.

Details
--------

This PR introduces a simple mechanism to configure express to rely on a custom `View` implementation without having to move the current implementation into a separate package or extra complexity. The proposal is to support this:

```
var app = express();
app.set('view constructor', CustomView);
app.render('something');
```

Where `CustomView` is a Class that mimics the api of `lib/view.js` which is responsible for exposing a method called `render` that will be invoked when calling `app.render`. How the view will be resolved based on the `name` and the `options` passed into `app.render` is irrelevant.

To-do
--------

* [x] code
* [x] test
* [ ] example