From e30545facf2a444f5dcd059d1a09aae80b8afcb2 Mon Sep 17 00:00:00 2001 From: Omer Ganim Date: Tue, 18 Aug 2015 10:32:43 +0300 Subject: [PATCH] update README.md to document inline templates --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 24bee2d..443123e 100644 --- a/README.md +++ b/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: + + }); + + 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 See the [Contributing page](CONTRIBUTING.md).