Formatters
These tools are used to adjust data types in certain useful manners to display or pass the information along to other functions.
The title of each formatter is followed by the alias used to invoke it in the xml page. For example, if you wanted to use DateTimeFormatter on a data type, you'd used
dt
in the actual code.
Note: the categories below are an attempt to organize the formatters by use case, but the inherit use of formatters means the that data type can be converted in many cases. For example the
Join
function converts a
List
to a
String
.
String formatters
SubstringFormatter (substr)
Return a sub section of the target string. If only one integer is given as a parameter, the substring will start at that index; if two are given, that is taken as a start and end marker for the substring.
<dcs.Var Name="TestVar1" Type="String" SetTo="Howdy yall" />
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dcs.Var Name="TestVar2" Type="String">
<Set Value="{$TestVar1|substr:0:5}" />
</dcs.Var>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is Howdy yall
TestVar2 is Howdy
ToStringFormatter (tostr)
Trim (trim)
Removes any trailing or proceeding white spaces from a string
<dcs.Var Name="TestVar1" Type="String" SetTo=" Hello " />
<dcs.Var Name="TestVar2" Type="String">
<Format Value="$TestVar1" Pattern="trim:" />
</dcs.Var>
<dcs.With Target="$TestVar1" >
<Prepend Value="START:" />
<Append Value=":END" />
</dcs.With >
<dcs.With Target="$TestVar2" >
<Prepend Value="START:" />
<Append Value=":END" />
</dcs.With >
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is START: Hello :END
TestVar2 is START:Hello:END
Lower (lower)
Converts a string into all lowercase characters
<dcs.Var Name="TestVar1" Type="String" SetTo="HellO" />
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dcs.Var Name="TestVar2" Type="String">
<Format Value="$TestVar1" Pattern="lower:" />
</dcs.Var>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is HellO
TestVar2 is hello
Upper (upper)
Converts a string into all uppercase characters
<dcs.Var Name="TestVar1" Type="String" SetTo="HellO" />
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dcs.Var Name="TestVar2" Type="String">
<Format Value="$TestVar1" Pattern="upper:" />
</dcs.Var>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is HellO
TestVar2 is hello
Numerical formatters
DecimalFormatter (dec)
Converts decimal into string for display purposes. The
Money
qualifier is a preset that will round up to two decimal places and add appropriate commas for a standardized dollar and cents display.
Explanation
<dcs.Var Name="TestVar1" Type="Decimal" SetTo="123334.44654" />
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dcs.Var Name="TestVar2" Type="String">
<Set Value="{$TestVar1|dec:Money}" />
<Prepend Value="$" />
</dcs.Var>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is 123334.44654
TestVar2 is $123,334.45
DateTimeFormatter (dt)
Will take any date string and convert it into a date/time value. The M, d, and u characters in the example below dictate where the month, day and year values respectively will be added. If the 4 digit year is desired, for example, one would use 'uuuu' instead of 'uu'. More on Java datetime formatting here .
<dcs.Var Name="TestVar1" Type="String" SetTo="2022-08-12" />
<dc.Out>TestVar1 is {$TestVar1}<br/></dc.Out>
<dcs.Var Name="TestVar2" Type="String">
<Format Value="$TestVar1" Pattern="dt:MM/dd/uu" />
</dcs.Var>
<dc.Out>TestVar2 is {$TestVar2}<br/></dc.Out>
Output:
TestVar1 is 2022-08-12
TestVar2 is 08/12/22
LocalDateFormatter (ld)
LocalTimeFormatter (lt)
List Formatters
TrimList (trimlist)
removes null and empty values from list
CleanList (cleanlist)
removes null and empty values from list, and replaces them with a default value
JoinFormatter (join)
converts list into single deliminated string
Slice (slice)
returns sub section of list
FieldToList (field2list)
converts selected fields of nested records to list
IndexFormatter (idx)
Finds index in a list
SplitFormatter (split)
Boolean formatters
YesNoFormatter (yn)
Takes a data type's Boolean value and converts to string Yes or No
TrueFalseFormatter (tf)
Takes a data type's Boolean value and converts to string True or False
URL/Path Formatters
ToSlug (toslug)
Gets ID out of URL
ImageGalleryToPath (img-g2p)
Trims img file path for use in dcs XML
ImagePathToGallery (img-p2g)
add to img file path for use in locating true file path
Url (url)
Converts string to URL
YouTubeId (youtubeid)
Pulls YT ID from several YT url formats
JSON formatters
EncodeJsonFormatter (encodejson)
DecodeJsonFormatter (decodejson)
PrettyJsonFormatter (prettyjson)
Encrypt/Decypt Formatters
Decrypt (decrypt)
Encrypt (encrypt)
Base64Decode (b64decode)
Base64Encode (b64encode)
Hash (hash)
HexDecode (hexdecode)
HexEncode (hexencode)
TODO Categorize These
AsciiFormatter (ascii)
Explanation
<Example>
Output:
Output
PdfTextFormatter (pdftext)
Explanation
<Example>
Output:
Output
CleanFilename (cleanfilename)
CleanEmailAddress (cleanemail)
TypeCast (cast)
XmlEscapeFormatter (xmlescape)
Adds XML escape chars to string
XmlUnescapeFormatter (xmlunescape)
Removes XML escape chars from string
EnumFormatter (tre)
NotEmptyFormatter (notempty)
EmptyFormatter (empty)
IfEmptyFormatter (ifempty)
MarkDown (md)
NumberPad (padnum)
PhoneE164 (phE164)
converts phone number to +1xxxxxxxxxx format