Expression tests: Formatting

This page tests that the formatting options available with Rivendell Expressions work as intended

Set up

No set up necessary. Just check below.

Results

Test Expected Actual Result
Format to two decimal places 2.75 2.75 PASS
Format to two decimal places with piped default 2.75 2.75 PASS
Format to two decimal places (via DB) 0.33 0.33 PASS
Format as currency 2.75 2.75 PASS
Format as currency (via DB) 0.33 0.33 PASS
Show label from foreign section My label My label PASS
Show label from literal list Two Two PASS
Show labels from literal list (using bits) A, C A, C PASS
Noparse on a string field from the database {some.foo} {some.foo} PASS
Noparse on a string field from the pagecontext (that contains dots) 10.5 10.5 PASS
Noparse on a double field from the database 10.5 10.5 PASS
Markup on string containing nasty HTML <script>alert('foo');</script> <script>alert('foo');</script> PASS
Safescript on string containing a single quote (i.e. for use in string var) Bill O\'Reilly Bill O\'Reilly PASS
Entities+ on string containing double quotes (i.e. for use in input field) Bill "Nutter" Stebson Bill "Nutter" Stebson PASS
Entities+ on string containing nasty HTML <script>alert('foo');</script> <script>alert('foo');</script> PASS
Remove on a string containing pipe character a string| a string| PASS
Replace on a string containing a pipe character a string| a string| PASS
RegExp-replace on a string containing a pipe character a string| a string| PASS
Truncate a string containing a pipe character a| string... a| string... PASS
Wordtruncate a string containing a pipe character a| string... a| string... PASS

Known problems and unsupported functionality

The Rivendell Expression Language is old and imperfect. It has many idiosyncrasies and contains many surprises. This means there are situations where it will not behave as you expect or desire. Where possible and sensible Rivendell is improved to combat these but at times the effort involved would not prove worthwhile - in many cases it would involve major rewrites of large portions of the code base. JSTL and the UEL are seen as longer term (and far saner) replacements for Rivendell Expressions.

Test Expected Actual Result
Remove a pipe character from a string a string INVALID FORMAT OPTION unsupported
Replace a pipe character in a string a string a|string unsupported
RegExp-replace a pipe character in a string a string a|string unsupported
Truncate a string with a pipe character a string| a string that is long unsupported
Wordtruncate a string with a pipe character a string| a string that is long unsupported