koa-jade-render
Jade for Koa with Spice.
Usage
npm install --save koa-jade-render
Note: I have not tested legacy but in theory it should work. Please report any bugs if encountered or create a pull request to add tests.
Legacy (< 2.0.0-alpha)
var koa = ;var app = ;var jade = ;var path = ; //set jadeapp; //then render!app; app;
Modern (>= 2.0.0-alpha)
var Koa = ;var app = ;var jade = ;var path = ; //set jadeapp; //then render!app; app;
Note: You can still pass locals if you like:
Example:
app; //the api is:this;//note that opt and locals will be merged//see example at https://github.com/jadejs/jade#api
Note: Jade uses jade.renderFile
to render its views. If you would like override the renderer, you can create a plugin and pass it into Jade.
Example:
//... //Jade takes two arguments, (opt, fn)//where opt is a String, PlainObject, or Function//and fn is a Function.app app;
Static API
jade.compile
- see http://jade-lang.com/api/
jade.render
- see http://jade-lang.com/api/
jade.renderFile
- see http://jade-lang.com/api/
Why another Jade middleware for Koa?
Because this middleware supports koa's this.state
and the code size is very small (~110 lines with beautiful comments!) so it's easier to maintain or contribute. Also, you're free to override or even create bad-to-the-bone plugins. Just name it something like koa-jade-render-MyAwesomePlugin
.
Example
An example is available. See the example
folder.
Contribute
You're more than welcome to contribute. This project isn't really a priority for me right now as I am working on another project where I am doing a major overhaul but if you would like to contribute, just do the standard Fork and Pull! Happy Coding!