How to Use Wrival Functions
Wrival has many built-in functions that can be used on variables or content by appending a colon followed by function names (separated by a space or comma for more than one) and their configuration values within a Wrival Insert. Each function will be processed from the left to the right and each will perform on the result of the last function. Any function configurations are all read first and will be applied to any function that uses them.
<#MyObject = "My Object!"> → My Object!
<#MyObject:upper> → MY OBJECT!
<#MyObject:upper,reverse> → !TCEJBO YM
<#MyObject:upper reverse> → !TCEJBO YM
<#MyObject: upper reverse> → !TCEJBO YM
To make functions dynamic you can embed other Wrival Inserts as desired:
Functions on Multiple Lines
More complicated Wrival Inserts can be written out in multiple lines as
in the following example. Just make sure there isn't a space on both
sides of the ending
> or else it will be interpreted as
the greater than comparison.
<#"A,B,C":each = '<#each:tag="li">'>
tag = 'ul'
Functions within Functions
As Wrival Inserts are processed by the deepest first (then left to right as needed) and outward, functions also are performed the same way. For example, setting a value to lowercase within a value first, but then also having uppercase function to the outer most include will ultimately return the value in uppercase.
<#A = '<#"Wrival":lower;code>'>→
<#A = '<#"Wrival":lower;code>':upper>→
Process (not all steps are displayed):
<#A = '<#"Wrival":lower;code>':upper>
<code>wrival</code>(#A is defined as this)
HTML Tag Generator
You can also use a semi-colon as a separator to wrap the result of the insert with an HTML tag. It will close automatically.
- weekday – Wednesday, today's weekday.
- :upper – WEDNESDAY, convert to uppercase.
- ;h3 – <h3>WEDNESDAY</h3>, wrap in an HTML tag.
Text to HTML
Wrival also has a Text to HTML feature where raw text is automatically converted to HTML using common patterns. See the Functions for HTML reference.
How to Use Wrival Conversions
IsType and ConvertTo or Default
must be valid and compatible types of conversions.
See the reference for each type for valid options.
No quotes are needed.
To make the value dynamic use a full include in its
Functions, Conversions, and HTML Tag Generator
- time – 1508361051, seconds since 1970.
- (seconds,days) – 17457.8825347222, convert to days.
- :round="2" – 17457.88, round to hundredths.
- ;h3 – <h3>17457.88</h3>, wrap in an HTML tag.