eval

An article by Gaspard Bucher

evaluate a RubyLess expression

  1. action
  2. ajax
  3. API
  4. classes
  5. common attributes
    1. ..._if
    2. actions
    3. anchor
    4. attr
    5. date selection
    6. draggable
    7. eval
    8. label
    9. link params
    10. name
    11. prefix
    12. publish
    13. set_...
    14. status
    15. store
    16. text, t
    17. tlabel
    18. toggle
  6. conditions
  7. context
  8. dates
  9. display
  10. forms
  11. i18n
  12. meta
  13. SQLiss
  14. urls

You can use this parameter to evaluated complex RubyLess expressions. The following example creates a link by using the link url as link text:

<r:link eval='url'/>

Please note that url is a helper method that takes the current node as default argument. See url.

obsolete docs to be removed

<r:set var='price'><r:show attr='d_price'/> 20.0</r:set>
<r:set var='count' do='stat' find='count'/>
<r:show eval='50 + ( price * count )' format='%.2f $'/>

<r:show eval='[d_total_hours] * 100.0' format='%.2f $'/>

In the example above, we use a trick to have a default value in case d_price is not set.

The value for “price” is set to 20.0 when d_price is empty or 25.0 20.0 when there is a value. The trick works because "25.0 20.0" as float is 25.0.

Also note that you have to use spaces between allowed signs in the expression. Currently permitted elements are:

* multiply
/ divide
+ add
( open parenthesis
) close parenthesis
[...] attribute
xyz set variable