Added streaming example to the Sample Code section

This commit is contained in:
Patrick Steele-Idem 2014-05-07 06:40:25 -06:00
parent 88702b2514
commit c9815aeddc

View File

@ -140,6 +140,19 @@ Hello World!
<div>No colors!</div> <div>No colors!</div>
``` ```
The streaming API can be used to stream the output to an HTTP response stream or any other writable stream. For example, with Express:
```javascript
var template = require('raptor-templates').load(require.resolve('./template.rhtml'));
app.get('/profile', function(req, res) {
template.stream({
name: 'Frank'
})
.pipe(res);
});
```
Raptor Templates also supports custom tags so you can easily extend the HTML grammar to support things like the following: Raptor Templates also supports custom tags so you can easily extend the HTML grammar to support things like the following:
```html ```html
@ -1286,7 +1299,6 @@ app.get('/profile', function(req, res) {
}) })
.pipe(res); .pipe(res);
}); });
``` ```
<hr> <hr>