0.0.3 • Published 12 years ago
ejs-middleware v0.0.3
node-ejs-middleware
Handles requests that match a *.ejs
file by rendering that file. Example usage:
var app = require('express').createServer(),
ejsMiddleware = require('ejs-middleware');
app.configure(function() {
app.use(ejsMiddleware(__dirname + '/static'));
}).listen(process.env.port || 3000);
Now for each incoming request, Node will look for a matching file under /static
. Examples:
- Request for
/
will matchyourapp/static/index.ejs
- Request for
/some/file
will matchyourapp/static/some/file.ejs
Request for
/some/dir
will matchyourapp/static/some/dir/index.ejs
Notice that, if the request matches a directory, ejsMiddleware appends index
automatically. Then, in all cases, it appends .ejs
. If there is such a file, it will be rendered out to the response. If there's no such file, ejsMiddleware does nothing, and your subsequent handlers can process the request.
Support
This is completely unsupported. No support questions, please! Seriously, it's only about 10 lines of code long, so if it doesn't do what you want, just grab the code and make your own modifications.