Renshi is a templating language for Ruby which is unobtrusive in HTML and XHTML structures.
$ Code
======
To output data on the page stick a $ in front of your var. or expression
$foo
$Time.now
If there's a space in your expression or you need formatting use ${}
${foo},$Time.now
To insert statements in your template use $[]
$[foo = "hello world"]
$[if foo]
$foo
$[end]
Attribute Expressions
===================
The $ syntax will give you everything ERB does, with less typing. But Renshi also has 'attribute expressions',
which can be inserted into a HTML element as an attribute - e.g. ....
r:expression_name="expression" - the expression value is treated as a Ruby expression .
Some expressions, such as r:each, use the quoted value to also hold parameter information.
Current Attribute Expressions
* If
* Unless
* Elsif
* Else
* While
* For
* Each
* If
hello would render "hello"
goodbye! will render "".
* Unless
e.g. hello
* Elsif
hello!
goodbye
* Else
hello!
goodbye
neither
r:elsif and r:else must be adjacent (a sibling) to the element.
For example, the below is fine, because the if and else statements are adjacent siblings in the tree of elements.
From the Renshi README at http://github.com/biv/renshi/tree/master
Leave a Reply