Sufio templates use filters to modify the outputs of the properties. Apply filters to format, style or edit the output values.
Filters will be applied on the output value of the selected property.
property | filter
Some filters work without any additional parameters.
property | filter(parameter=value)
Expand the abilities of filters by using them with parameters. Selected filters work only when a parameter is provided.
property | filter1 | filter2
You may use more than one filter on a property. The filters will be applied in sequence from left to right.
Use the array filters to manipulate, modify or map other filters on arrays or, in some cases, strings.
array | batch(count: integer)
Batches items by the given number and returns an array of arrays.
array | batch(count: integer, fill_with: string)
Use the fill_with
parameter to fill an incomplete array to the given count.
array | chunk(count: integer)
Splits an array and returns an array of the given number of arrays.
array | chunk(count: integer, collate: boolean)
Use the collate
parameter to collate items when slicing an array. This can be useful to create lists that represent columns. The default value is False
.
array | chunk(count: integer, fill_with: string)
Use the fill_with
parameter to fill up missing items in each array.
array | first
Returns the first item of an array.
string | first
Returns the first character of a string.
array | join
Combines all items of an array into a string.
array | join(separator: string)
Use the separator
parameter to separate the items with the specified string. By default, items are combined without a separator.
array | last
Returns the last item of an array.
string | last
Returns the last character of a string.
array | length
Returns the number of items in an array.
string | length
Returns the number of characters in a string.
Applies a filter on all items in an array or creates an array of property values.
array | map(filter: string)
Applies specified filter on all items in an array.
array | map(property: string, default: string)
Creates an array of property values. Use the default
parameter to set default values for empty properties in case the specified property is not found.
array | reject(property: string, value: string)
Returns an array that excludes items based on their property value.
array | reverse(join: string)
Reverses the order of items in an array. Use the join
parameter to separate the items with the specified string. By default, items are combined without a separator.
string | reverse
Use the filter to reverse a string.
array | select(property: string, value: string)
Creates an array that includes items based on a property value.
array | sort
Sorts the items in an array in alphabetical or numerical order.
array | sort(reverse: boolean)
Use the reverse
parameter to sort the array items in reverse alphabetical or numerical order. The default value is False
.
array | sort(case_sensitive: boolean)
Use the case_sensitive
parameter to sort the array items in case-sensitive order. The default is False
.
array | sort(property: string)
Use the property
parameter to sort the array items by their property in alphabetical or numerical order.
string | sort
Sorts the characters of a string.
array | unique
Removes any duplicate items from the array. By default, the filter is not case-sensitive.
array | unique(case_sensitive: boolean)
Use the case_sensitive
parameter to keep all case-sensitive variations of one item. The default value is False
.
array | unique(property: string)
Use the property
parameter to remove the duplicate array items by their property.
Barcode filters generate machine-readable barcodes from strings.
string | qr_code
Renders the string as a QR code.
string | qr_code(scale: float)
Use the scale
parameter to resize the QR code. The default value is 2
.
string | qr_code(border: integer)
Use the border
parameter to add a border around the QR code. The default value is 0
.
string | qr_code(color: string)
Use the color
parameter to change the color of the QR code. Accepts color names and hex codes. The default color is black
.
string | qr_code(background: string)
Use the background
parameter to change the color of the background of the QR code. Accepts color names and hex codes. The default color is white
.
string | qr_code(title: string)
Use the title
parameter to add an image title to the generated QR code.
string | qr_code(logo: string, logo_width: string)
Use the logo
parameter to add an image to the center of the QR code. Use the logo_width
parameter to resize the logo. Supports all common image formats.
string | qr_code_ksa
Auto-fills and creates QR codes for invoices in Saudi Arabia. We recommend you insert the filter as a function without any input property.
Can be used with the same parameters as qr_code
.
Design filters apply additional styles to your document values.
string | font_size_to_fit_text(max_width: string)
Returns a font-size
style in em
that will downsize the provided string so that the entire string fits the width defined by the max_width
parameter. If no downsizing is needed, the filter does not return anything.
This filter ensures that the entire text, such as a document name, fits into a single line.
Use the filter as a property in the style attribute.
string | font_size_to_fit_text(max_width: string, fit_words: boolean)
Use the fit_words
parameter to return a font size that will fit all individual words of the provided string. The default value is False
.
This parameter ensures that the individual words of a text fit into a single line, while allowing the entire text to break across multiple lines.
Use format filters to apply specific formatting on objects, such as strings, integers, or dates.
string | date
Converts a string with date or combined date and time format to ISO 8061 date and time format.
string | date(format: string)
Converts a string in a custom date format to an ISO 8601 date and time format. Use the format
parameter to specify the original date format according to the Python strftime/strptime format codes.
now()
Returns the current date and time in your account’s timezone.
string | default(string)
Sets a default value for any variable that has an empty string, an empty array, False
, or None
as its value.
date | delta(parameter: string)
Adds or subtracts an amount of time specified in seconds, minutes, hours, days, weeks, months or years.
string | format(format_string: string)
Applies specified values to a printf-style format string.
For example, use the filter with the %0xd
value as a parameter, where x
specifies the number of digits, to add zeroes to the beginning of a number.
Use the filter with the %.xf
value as a parameter, where x
specifies the number of decimals, to truncate the number of decimal places of a float.
date | format_date
Returns the date as a string in the format based on the document language.
date | format_date(format: string)
Use the format
parameter to define a custom date format according to the Python strftime/strptime format codes.
Use the year
, month
, day
, hour
, minute
or second
properties of a date to return the specific part of the date.
string | label(title: string)
Adds a label, suffixed by a colon, before a string. If the string is empty, no label is added.
number | money
Formats a given number as an amount in the document’s currency. By default, this includes the currency symbol, such as the dollar sign ($), and the correct number of decimals.
number | money(include_symbol: boolean)
Use the include_symbol
parameter to format the amount with or without the currency symbol. The default value is True
.
number | money(include_code: boolean)
Use the include_code
parameter to format the amount to include the ISO 4217 three-letter currency code, such as USD. The default value is False
.
number | money(remove_zeros: boolean)
Use the remove_zeros
parameter to format the amount without any trailing decimal zeros. The default value is False
.
number | number_to_words
Converts numbers to words in the document language.
number | number_to_words(language_code: string)
Use the language_code
parameter to specify a language in which the number should be displayed. Use a two-letter language code from this list. The default value is the language code of your document.
number | number_to_words(format: string)
Use the format
parameter to specify the type of the converter to use. Supported values are:
cardinal
(default): Converts the input number to cardinal word form to express quantity.
ordinal
: Converts the input number to ordinal word form to express position or rank.
ordinal_num
: Converts the input number to ordinal number form with the appropriate suffix (e.g., 1st, 2nd, 3rd).
year
: Converts the input number into its word form as a year.
currency
: Converts the input number into words as a monetary amount. The input number must include decimals.
string | tlv(tag: integer)
Encodes string to TLV format. Some QR codes use this format to encode different values.
date | to_timezone(timezone: string)
Converts the datetime to a specified timezone. Use the timezone
parameter to specify the timezone as an abbreviation or a full name. The default value is the timezone of your account.
Math filters help you with calculations on your documents.
array | max
Returns the largest item from an array.
array | max(case_sensitive: boolean)
Use the case_sensitive
parameter to return the largest item in a case-sensitive manner. Lowercase letters have larger value than uppercase. The default value is False
.
array | max(property: string)
Use the property
parameter to specify by which property the item with the largest value will be returned. Returns the whole item in which the value is found.
array | min
Returns the smallest item from an array.
array | min(case_sensitive: boolean)
Use the case_sensitive
parameter to return the smallest item in a case-sensitive manner. Uppercase letters have smaller value than lowercase. The default value is False
.
min(property: string)
Use the property
parameter to specify by which property the item with the smallest value will be returned. Returns the whole item in which the value is found.
number | round
Rounds a number to the nearest integer.
number | round(decimals: integer)
Use the decimals
parameter to specify the number of decimal places to round to.
array | sum
Returns the sum of an array of numbers.
array | sum(property: string)
Use the property
parameter to sum the property values.
array | sum(start: integer)
Use the start
parameter to specify a starting number that is added to the sum.
Use the string filters to format or convert strings.
string | capitalize
Converts a string so that the first character is uppercase and the rest are lowercase.
string | escape
Replaces the characters &
, <
, >
, '
, and "
in the string with HTML name codes. Useful to display text that might contain HTML tags.
string | hash(algorithm: string)
Converts a string to a hash. Supports the following algorithms:
- crc32
- sha1
- sha224
- sha256
- sha384
- sha512
- blake2b
- blake2s
- md5
- sha3_224
- sha3_256
- sha3_384
- sha3_512
string | pluralize(singular: string, plural: string)
Returns the singular or plural version of a string based on the given parameter.
string | replace(old: string, new: string)
Replaces the specified part of a string with a different string.
string | replace(old: string, new: string, count: integer)
Use the count
parameter to specify how many occurrences will be replaced.
string | slice(start: integer, length: integer)
Returns the specified part of a string or an array. Specify the first character of the part to be sliced out and the length. The numbering is zero-indexed, meaning the first item of the input has index value 0.
string | slugify
Converts to lowercase and removes all characters except alphanumeric, underscores, or hyphens. Replaces whitespace characters with hyphens. Strips whitespace characters at the beginning and at the end of a string.
string | split
Splits a string with whitespace characters as the separator into an array of strings.
string | split(separator: string)
Use the separator
parameter to specify a custom character that will be recognized as the separator.
string | strip
Strips whitespace characters at the beginning and at the end of a string.
string | strip(chars: string)
Use the chars
parameter to specify custom characters to be removed at the beginning and at the end of a string.
string | strip_html
Removes HTML tags and replaces adjacent whitespace characters with one space.
string | truncate(length: integer)
Returns a truncated copy of the string with the specified number of characters. If the string is longer than the specified length, whole words over the limit are cut. The default value is 255
.
string | truncate(length: integer, kill_words: boolean)
Use the parameter kill_words
to slice the word over the specified length instead of cutting it out whole. The default value is False
.
string | truncate(length: integer, end: string)
Use the end
parameter to specify custom ending characters. The default value is an ellipsis sign (…
).
string | truncate_words(length: integer)
Returns a truncated copy of the string with a specified number of words.
string | truncate_words(length: integer, end: string)
Use the end
parameter to specify custom ending characters. The default value is an ellipsis sign (…
).
string | url_encode
Converts a string to URL-safe format by percent-encoding special characters. This ensures that the string can be included in a URL.
string | urlize
Convert URLs in a string to clickable links.
string | urlize(truncate_length: integer)
Use the truncate_length
parameter to shorten the displayed link to a specified length. By default, the whole length is displayed.
string | urlize(target: string)
Use the target
parameter to add target attribute to the link. For example, target='_blank'
can be used to open the target page in a new tab.