Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 62403c3

Browse files
committed
Update README for markup usage
1 parent 22fe3bd commit 62403c3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ React.render(React.create_element(App), `document.body`)
118118
* Use helper method `define_state` to create setter & getter of `this.state` for you
119119
* For the detailed mapping to the original API, see [this issue](https://github.com/zetachang/react.rb/issues/2) for reference. Complete reference will come soon.
120120

121+
### Element Building DSL
122+
123+
As a replacement of JSX, include `React::Component` and you can build `React.Element` hierarchy without all the `React.create_element` noises.
124+
125+
```ruby
126+
def render
127+
div do
128+
h1 { "Title" }
129+
h2 { "subtitle"}
130+
div(class_name: 'fancy', id: 'foo') { span { "some text #{interpolation}"} }
131+
present FancyElement, fancy_props: '10'
132+
end
133+
end
134+
```
135+
121136
### Props validation
122137

123138
How about props validation? Inspired by [Grape API](https://github.com/intridea/grape), props validation rule could be created easily through `params` class method as below,

0 commit comments

Comments
 (0)