Filters

Filters assist in formatting templates. Below is a list of filters commonly used in Knackly:

Filter Parameters Example This example… Converts… To… Notes
upper (none) TextVar | upper Formats TextVar in all upper case text text Converts any text value to all uppercase
lower (none) TextVar | lower Formats TextVar in all lower case text text Converts any text value to all lowercase
initcap forceLower: optional true/false TextVar | initcap Capitalizes the first letter of TextVar, and leaves the rest as-is text text Capitalizes the first letter of a text value. If :true is specified, the rest of the letters are forced to lower case (otherwise they are left as-is)
titlecaps forceLower: optional true/false TextVar | titlecaps : true Capitalizes the first letter of each word in TextVar, and forces the rest to lowercase text text Capitalizes the first letter of each word in a text value. If :true is specified, the rest of the letters are forced to lower case (otherwise they are left as-is)
format formatStr: text string DateVar | format: "DD MMM YYYY" Formats DateVar like "09 JUN 2019" date text Formats a date according to a format string as defined here: https://date-fns.org/v1.30.1/docs/format
format formatStr: text string NumVar | format: "0,0" Formats NumVar like "9,999" number text Formats a number according to a format string as defined here: http://numeraljs.com/#format
cardinal (none) NumVar | cardinal Spells a cardinal number (in English), like "nine" number text
ordinal (none) NumVar | ordinal Spells an ordinal number (in English), like "ninth" number text
ordsuffix (none) NumVar | ordsuffix If NumVar is 1, this produces "st" number text Returns the ordinal suffix appropriate for the given number: "st", "nd", "rd" or "th"
else text string TextVar | else: "no value supplied"
missing value text Does nothing if it's given a value, but if it's not given a value, it returns whatever text it is supplied with
punc text string ListVar | punc: "1, 2 and 3."

if list is ["Hello"] => "Hello."

if list is ["A", "B"] => "A and B."

if list is ["A", "B", "C"] => "A, B and C."

list list Does not modify the given list, except that it specifies how that list should be punctuated when repetitions are inserted into a template. If used together with other list filters, punc should be last — the list will "forget" how it's supposed to be punctuated if it is subsequently filtered.
contains text, number, date, or object value SelectionList | contains: "value" Determines whether SelectionList contains "value" list true/false

ListVar can be any list variable — a text list, selection list, or object list. For object lists, the value you are searching for should be an object in JavaScript syntax:

ObjectList | contains: { FirstName: "John", LastName: "Smith" }

sort

expression (optionally preceded by + or -)

Beneficiaries | sort: +LastName : -FirstName Sort the list of beneficiaries ascending by last name, then (within the same last name) descending by first name list list Returns the given list of items in the specified order. You must specify at least one sort criterion, but you may specify as many as necessary.
filter condition: expression Children | filter: Age < 18 Filter the list to include only those children whose age is less than 18 list list Filters the given list to include only items that meet some condition
find condition: expression Parties | find: Role == 'Executor' Find the first item in the list where the value of the Role variable equals "Executor" list value Finds the first item in a list that meets some condition. Just like Filter, but it only returns a single value, for times when you only care about that one value.
any condition: expression Children | any: Age < 18 Returns true if any (one or more) items in the Children list have an Age less than 18; otherwise returns false list true/false Determines whether any item(s) in a list meet a certain condition
every condition: expression Children | every: Age < 18 Returns true if every item in the Children list has an Age less than 18; otherwise returns false list true/false Determines whether every item in a list meets a certain condition
map transform: expression Children | map: Name Produces a simple list of text values from the "Name" property of each item in the Children list list list Maps (transforms) a list of items into a list of something else, by evaluating the given expression for each item in the list, and returning a list of the results
group key: expression Children | group: date.yearOf(Birth) Produces a list of objects, where each object has a 2 variables: one called _key, which (in this case) will contain birth years, and another called _values, which will be a list of Children born in that birth year. list list of groups Subdivides a list of items into a list of groups of items.  Each group is an object with two properties: _key and _values.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us