A swig extension to allow React components to be embedded and precompiled in Swig templates.
Right now have to install from github:
$ npm install git://github.com/jnu/swig-react.git#v0.0.1 --save
Extend swig with this module:
var swig = require('swig');
require('swig-react').useTag(swig);
You can now use the react
tag in swig templates.
The following examples use this component:
var FruitGreeting = React.createClass({
getDefaultProps: {
fruit: "banana"
},
render: function() {
return (
<span>
Hello, {this.props.fruit}!
</span>
);
}
});
{% react "FruitGreeting" %}
will output:
<div>
<span react-...>
Hello, banana!
</span>
</div>