A microframework for Bottle+React projects.
Project description
bottle-react
============
Description
-----------
This library allows you to return react components from Bottle. It
currently powers https://www.hvst.com/.
Example
-------
Assume you have a normal JSX file ``hello_world.jsx``:
.. code:: js
var HelloWorld = React.createClass({
render: function() {
return (
<div className='hello_world'>
<h1>Hello {this.props.name}!</h1>
<div>
Thanks for trying bottle-react!
</div>
</div>
);
}
})
bottlereact._register('HelloWorld', HelloWorld)
And some python code:
.. code:: python
app = bottle.Bottle()
br = BottleReact(app)
@app.get('/')
def root():
return br.render_html(
br.HelloWorld({'name':'World'})
)
You will have a functioning bottle+react app.
Install
-------
.. code:: python
sudo pip install bottle-react
Documentation
-------------
``bottlereact.BottleReact()`` takes several keyword arguments, all of
which are optional:
+--------------+--------------+----------+
| KW Argument | Description | Default |
+==============+==============+==========+
| ``prod`` | Are we in | False |
| | production? | |
| | If so, | |
| | compile all | |
| | JSX into | |
| | pure | |
| | javascript. | |
| | Otherwise | |
| | serve the | |
| | raw JSX with | |
| | the | |
| | babel-core | |
| | shim. | |
+--------------+--------------+----------+
| ``jsx_path`` | Where | ``jsx`` |
| | bottle-react | |
| | should | |
| | search for | |
| | JSX files. | |
+--------------+--------------+----------+
| ``asset_path | Where | ``assets |
| `` | bottle-react | `` |
| | should | |
| | search for | |
| | javascript/c | |
| | ss/etc | |
| | files. | |
+--------------+--------------+----------+
| ``work_path` | Where | ``/tmp/b |
| ` | bottle-react | ottlerea |
| | outputs | ct`` |
| | static js | |
| | files when | |
| | in | |
| | production | |
| | mode (if you | |
| | want to | |
| | serve them | |
| | statically). | |
+--------------+--------------+----------+
| ``jsx_path`` | Where | ``jsx`` |
| | bottle-react | |
| | should | |
| | search for | |
| | JSX files. | |
+--------------+--------------+----------+
| ``verbose`` | Verbose | ``not pr |
| | mode. | od`` |
+--------------+--------------+----------+
============
Description
-----------
This library allows you to return react components from Bottle. It
currently powers https://www.hvst.com/.
Example
-------
Assume you have a normal JSX file ``hello_world.jsx``:
.. code:: js
var HelloWorld = React.createClass({
render: function() {
return (
<div className='hello_world'>
<h1>Hello {this.props.name}!</h1>
<div>
Thanks for trying bottle-react!
</div>
</div>
);
}
})
bottlereact._register('HelloWorld', HelloWorld)
And some python code:
.. code:: python
app = bottle.Bottle()
br = BottleReact(app)
@app.get('/')
def root():
return br.render_html(
br.HelloWorld({'name':'World'})
)
You will have a functioning bottle+react app.
Install
-------
.. code:: python
sudo pip install bottle-react
Documentation
-------------
``bottlereact.BottleReact()`` takes several keyword arguments, all of
which are optional:
+--------------+--------------+----------+
| KW Argument | Description | Default |
+==============+==============+==========+
| ``prod`` | Are we in | False |
| | production? | |
| | If so, | |
| | compile all | |
| | JSX into | |
| | pure | |
| | javascript. | |
| | Otherwise | |
| | serve the | |
| | raw JSX with | |
| | the | |
| | babel-core | |
| | shim. | |
+--------------+--------------+----------+
| ``jsx_path`` | Where | ``jsx`` |
| | bottle-react | |
| | should | |
| | search for | |
| | JSX files. | |
+--------------+--------------+----------+
| ``asset_path | Where | ``assets |
| `` | bottle-react | `` |
| | should | |
| | search for | |
| | javascript/c | |
| | ss/etc | |
| | files. | |
+--------------+--------------+----------+
| ``work_path` | Where | ``/tmp/b |
| ` | bottle-react | ottlerea |
| | outputs | ct`` |
| | static js | |
| | files when | |
| | in | |
| | production | |
| | mode (if you | |
| | want to | |
| | serve them | |
| | statically). | |
+--------------+--------------+----------+
| ``jsx_path`` | Where | ``jsx`` |
| | bottle-react | |
| | should | |
| | search for | |
| | JSX files. | |
+--------------+--------------+----------+
| ``verbose`` | Verbose | ``not pr |
| | mode. | od`` |
+--------------+--------------+----------+
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bottle-react-0.1.2.tar.gz
(6.5 kB
view hashes)