update README.md to document inline templates
This commit is contained in:
parent
d565f5380f
commit
e30545facf
38
README.md
38
README.md
|
@ -361,6 +361,44 @@ export default function () {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Inline Templates
|
||||||
|
Although we recommend separating the templates to a separate `.rt` file, there's an option to use a template inline as the render method (à la JSX).
|
||||||
|
To do that, write your code in a `.jsrt` file, and send it to react-templates with the `modules` flag set to `jsrt`.
|
||||||
|
###### Sample:
|
||||||
|
```javascript
|
||||||
|
define(['react','lodash'], function (React, _) {
|
||||||
|
var comp = React.createClass({
|
||||||
|
render:
|
||||||
|
<template>
|
||||||
|
<div>hello world</div>
|
||||||
|
</template>
|
||||||
|
});
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Compiled (with jsrt flag):
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
|
||||||
|
define([
|
||||||
|
'react',
|
||||||
|
'lodash'
|
||||||
|
], function (React, _) {
|
||||||
|
var comp = React.createClass({
|
||||||
|
render: function () {
|
||||||
|
return function () {
|
||||||
|
return React.createElement('div', {}, 'hello world');
|
||||||
|
};
|
||||||
|
}()
|
||||||
|
});
|
||||||
|
return comp;
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
See the [Contributing page](CONTRIBUTING.md).
|
See the [Contributing page](CONTRIBUTING.md).
|
||||||
|
|
Loading…
Reference in New Issue