The Built-in Operator
Many expressions have certain built-in attributes that you can use.
The operator for built-ins is the question mark.
(?) to separate it from the expression instead of the dot (.). For instance,
<assign x="welcome to the zoo">
${x?capitalize}
Will render as "Welcome To The Zoo", since the built-in "capitalize" will
capitalize every word of the string expression to which it is applied.
The built-ins for strings are:
Built-in | effect |
length | returns the length of the string |
lower_case | returns the string in lower case |
upper_case | returns the string in upper case |
capitalize | return the string with all words capitalized |
trim | returns the string with leading and trailing whitespace removed |
number | returns the string converted to a number |
string | simply returns the same string, this exists for symmetry |
word_list | returns a collection/sequence
with substrings of the string separated by whitespace |
web_safe | returns the string with
problematic characters such as '<" and '>" converted
to the appropriate HTML entities. |
The built-ins for numerical variables are:
Built-in | effect |
byte | converts the number to Java byte |
short | converts the number to Java short |
int | converts the number to Java int |
long | converts the number to Java long |
float | converts the number to Java float |
double | converts the number to Java double |
string | converts the number to string |
number | simply returns the same number, exists for symmetry |
The built-ins for sequences are:
Built-in | effect |
size | returns the number of items in a sequence |
first | returns the first (that is, 0th) element |
last | returns the last (that is, (size-1)th) element |
reverse | returns a sequence with the elements in reverse order |
The built-ins for hashes are:
Built-in | effect |
size | returns the number of key/value pairs in the hash |
keys | returns a sequence consisting of the keys in the hash. |
values | returns a sequence consisting of the values in the hash. |
|