Table of Contents generated with DocToc
- Beidou react view
- Configuration
- Usage
- API
Beidou react view
=================
> React view
```
$ npm install beidou-plugin-react --save
- config/plugin.default.js:
` `
exports.react = {
enable: true,
package: 'beidou-plugin-react',
};
- config/config.default.js
`
exports.react = {
beautify: false // optional, beautify HTML snippet
cache: true, //optional, if false, clean require cache for development usage
internals: true, //optional, true: renderToString or false: renderToStaticMarkup
doctype: '', //optional, HTML doctype
}
exports.view = {
defaultViewEngine: 'react',
defaultExtension: '.jsx'
}
`
` `
// app/controller/index.js
exprots.index = function*() {
yield this.render('path/to/index.jsx', {
user: 'beidou view'
});
};
React view exports render and renderString 2 APIs, return Promise.
> * ctx.render(name, locals) - render template, and assign to ctx.body
> * ctx.renderString(tpl, locals) - only render template to string, will not` assign to ctx.body