Difference between revisions of "EPScript/Functions"
(→Functions) |
|||
Line 2: | Line 2: | ||
= Functions = | = Functions = | ||
+ | |||
+ | == Calling Functions == | ||
+ | |||
+ | Functions can be called in two ways: | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <when test="is_set( creators )"> | ||
+ | </pre> | ||
+ | }} | ||
+ | |||
+ | or | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <when test="creators.is_set"> | ||
+ | </pre> | ||
+ | }} | ||
+ | |||
+ | These are interchangable, but it may be beneficial to use a specific form in some cases. | ||
+ | |||
+ | == Generic Functions == | ||
+ | |||
+ | === is_set === | ||
+ | |||
+ | Returns true if the parameter is set, based on the following criteria: | ||
+ | * If the parameter is a string, it is set if it is not empty. | ||
+ | * If the parameter is a list or a complex structure, it is set if at least one value is set. | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <when test="is_set( creators )"> | ||
+ | ... | ||
+ | </when> | ||
+ | </pre> | ||
+ | }} | ||
+ | |||
+ | == List Functions == | ||
+ | |||
+ | === length === | ||
+ | |||
+ | Returns the number of items in the list. | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <if test="length(editors) gt 1">s</if> | ||
+ | </pre> | ||
+ | }} | ||
+ | |||
+ | == String Functions == | ||
+ | |||
+ | === one_of === | ||
+ | |||
+ | Returns true if the string is in the list of strings provided. | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <when test="type.one_of( 'book','book_section' )"> | ||
+ | ... | ||
+ | </when> | ||
+ | </pre> | ||
+ | }} | ||
+ | |||
+ | === reverse === | ||
+ | |||
+ | Returns the reverse of a string (i.e. 'abc' becomes 'cba'). | ||
+ | |||
+ | {{codesample| | ||
+ | <pre> | ||
+ | <when test="type.reverse = 'tnetap'"> | ||
+ | ... | ||
+ | </when> | ||
+ | </pre> | ||
+ | }} |
Revision as of 15:14, 4 October 2006
EPScript | ||||||
← Operators | Functions | XML Syntax → | ||||
|
Contents
Functions
Calling Functions
Functions can be called in two ways:
<when test="is_set( creators )">
or
<when test="creators.is_set">
These are interchangable, but it may be beneficial to use a specific form in some cases.
Generic Functions
is_set
Returns true if the parameter is set, based on the following criteria:
- If the parameter is a string, it is set if it is not empty.
- If the parameter is a list or a complex structure, it is set if at least one value is set.
<when test="is_set( creators )"> ... </when>
List Functions
length
Returns the number of items in the list.
<if test="length(editors) gt 1">s</if>
String Functions
one_of
Returns true if the string is in the list of strings provided.
<when test="type.one_of( 'book','book_section' )"> ... </when>
reverse
Returns the reverse of a string (i.e. 'abc' becomes 'cba').
<when test="type.reverse = 'tnetap'"> ... </when>