recup
v1.0.0
Published
React.createElement in the style of teacup.
Downloads
4
Maintainers
Readme
Recup
Recup is Teacup (templates in CoffeeScript) for React.
A beautiful DSL for building React elements. JSX doesn't play nice with CoffeeScript, and raw React is ugly - Recup is the answer.
See Teacup for docs, since this is meant to mirror it very closely.
Differences from Teacup
- The top-level render function must return exactly one root element (and it can't be a text element). Just wrap it in a
div
if this presents a problem. t.raw
wraps its contents in aspan
tag.style
attribute is expected to be an object instead of a string, in the style of React. The camelCase to kebab-case conversion will be done for you, so usebackgroundColor
, notbackground-color
.- Contents can only be specified as a function. None of this
h1 "contents"
stuff.- This is an intentional breakage - if the contents are a dynamic string, one day they will be interpreted as a selector because of a leading
.
or#
, and then everything goes wrong.
- This is an intentional breakage - if the contents are a dynamic string, one day they will be interpreted as a selector because of a leading
class
is aliased toclassName
. Specifying both will result in an error.- The functions
coffeescript
,escape
,script
,ie
,style
, anduse
are missing. Also, probably others.- Yep, no plugins. Sorry.
- Returning a string from a contents function doesn't work. Use
t.text
instead. - Self-closing tags don't error if you try to specify contents. React will do whatever it does with the contents.