String
Remove
Removes the argument in a given string.
{{ "BE0.524.802.662" | remove:"BE" }}
Replace
Replaces the argument_1 by argument_2 in the given string.
{{ "Comm.VA" | replace:".","" }}
Upcase
Turns all letters of the string in capital letters
{{ "Silverfin" | upcase }}
Downcase
Puts all letters of the string in small letters.
{{ "Silverfin" | downcase }}
Capitalize
Turns the first letter of the string into a capital letter.
{{ "silverfin" | capitalize }}
Append
Attaches the argument string after the given string.
{{ "Tim Vandecasteele" | append:” with a representative” }}
Prepend
Attaches the argument string before the given string.
{{ "9050 Ledeberg" | prepend:"B - " }}
Size
Returns the numbers of characters in a string.
{{ "BE0.524.802.662" | size }}
Strip
Removes all whitespaces before and after a given string (it doesn't remove spaces between words).
{{ " BE0.524.802.662 " | strip }}
Default
This allows to set a default value when a variable or [linkto database variable]database variable[endlinkto] is nil, false or empty
{% assign company_form = company.company_form | default:”NV” %}
Let's say that the database variable company.company_form has not been inputted any value in the company settings
{{ company_form | default:"NV" }}
Minus
Using a minus will remove initial zeros.
Without minus:
{{ "01/01/2018" | date:"%d %B %Y" }}
With minus:
{{ "01/01/2018" | date:"%-d %B %Y" }}
01 January 2018
With minus:
1 January 2018
Today
To the date of today, you can do the following:
{{ "now" | date:"%d/%m/%Y" }}
Localized Date
If you need to display a date according to the time-zone from where template is being executed, you can used the "localized_date" filter.
This date will be only shown in the user's browser, but won't be exported to the PDF file.
{{ "now" | localized_date:"%d/%m/%Y %H:%M" }}
Slice
Gives a substring of a given string, beginning from a certain index that can be given as well the length of the substring.
{{ "BE0.524.802.662" | slice:4, 11 }}
Newline_to_br / multiline_table
These filters replace every newline character ("\n") in a string with an HTML line break tag ("
"). This ensures that text is displayed on new lines as intended.
{% capture welcome_string %}
Hello,
World!
{% endcapture %}
With filter:
{{ welcome_string | newline_to_br }}
Or:
{{ welcome_string | multiline_table }}
Without filter:
{{ welcome_string }}
<br />
Hello,<br />
World!<br />
Without filter:
Hello, World!
String_value
Values are stored as string, but whenever a variable or drop is called, Silverfin will try to infer it's type (string, number, etc). In some situation we could prefer to avoid this and render the value always as a string.
{% input custom.some.field %}
Value: {{ custom.some.field }}
String value: {{ custom.some.field.string_value }}
Url_encode
Replaces any URL-unsafe character with three characters: a percent sign and the corresponding Hex value of the character replaced.
{{ "[email protected]" | url_encode }}
Url_decode
Decodes a string that has been encoded by url_encode. It will replaces the Hex values with URL-unsafe characters.
Strip_html
Removes any HTML tags from a string.
{% capture formatted_text %}This is a <i>text</i>.<br>There is some <strong>HTML</strong>.<br>Which we want to <sup>remove</sup>{% endcapture %}
Without filter:
{{ formatted_text }}
With filter:
{{ formatted_text | strip_html }}
This is a text.
There is some HTML.
Which we want to remove
With filter:
This is a text.There is some HTML.Which we want to remove
MD5
Converts a string into an MD5 hash so developers are able to produce hashes of values. Can be used to protect sensitive information. MD5 is one of the most widely used hashing algorithms.
{% assign person_national_number = "920711-216-81" %}
{{ person_national_number | md5 }}
---
{% assign person_national_number = person_national_number | md5 %}
{% input custom.[person_national_number].name %}
Transliterate
Transliterates strings based on the Unicoder library. This library converts Unicode [and accented ASCII] characters to their plain-text ASCII equivalents. The filter is particularly useful to transliterate special characters like é, è, ä, etc.
{% input custom.person.full_name %}
{{ custom.person.full_name | transliterate }}
Updated 6 months ago