Skip to content

RPT Filters

Peter Johnson edited this page Feb 3, 2023 · 42 revisions

rpt Filters

⚠️⚠️ THIS WIKI IS BEING USED TO JOT DOWN IDEAS AT PRESENT. DON'T ASSUME ANYTHING IS FIXED. ⚠️⚠️

⚒️ MORE TO COME: Check back later

The filters listed on this page are unique to rpt, they are not copies of Liquid filters.

Filters that are not yet implemented are marked with a ⛔ symbol.

Mathematical Filters

Filter Parameters Input Type Output Type Notes
div ⛔ Int Int Int Returns the input divided by the parameter using integer division. Parameter must not be zero.
divide ⛔ Int or Float Int or Float Float Returns the input divided by the parameter floating point division. The parameter must not be zero.

NOTE: div and divide are both subtlety different to the Liquid divided_by filter.

Date Filters

Filter Parameters Input Type Output Type Notes
year ⛔ none DateTime Int Year number.
month ⛔ none DateTime Int Month number within year (1..12).
day ⛔ none DateTime Int Day of month (1..31).
hour ⛔ none DateTime Int Hour of day (1..24).
minute ⛔ none DateTime Int Minute of hour (0..59).
second ⛔ none DateTime Int Second of minute (0..59).
millis ⛔ none DateTime Int Millisecond of minute (0..999).
day-of-week ⛔ none DateTime Int Day of week (1..7) per ISO 8601.
day-of-year ⛔ none DateTime Int Day of year per ISO 8601.
week-of-year ⛔ none DateTime Int Week of year per ISO 8601.
month-name ⛔ none DateTime Text Full name of month in current locale.
month-abbrev ⛔ none DateTime Text Abbreviated name of month in current locale.
day-name ⛔ none DateTime Text Full name of day of week in current locale.
day-abbrev ⛔ none DateTime Text Abbreviated name of day of week in current locale.
iso-datetime ⛔ Boolean DateTime Text Date and time value in ISO 8601 format. If the parameter is true then date is in UTC format, else date is in local time for the current locale. The UTC form of this function is the DateTime default string.
am-pm ⛔ none DateTime Text AM or PM indicator in current locale.
time-am-pm ⛔ none DateTime Text Time rendered using 12 hr clock with AM or PM indicator in current locale.
utc-to-local ⛔ none DateTime DateTime Converts a DateTime in UTC to a local DateTime in the current locale.
local-to-utc ⛔ none DateTime DateTime Converts a local DateTime in the current locale to a DateTime in UTC.
era ⛔ none DateTime Int Era number.
era-name ⛔ none DateTime Text Full name of era.
era-abbrev ⛔ none DateTime Text Abbreviated name of era.

Formatting filters

Filter Parameters Input Type Output Type Notes
pad-left ⛔ (x) Int, (y) Text Text Text Pads the input text on the left to a maximum width of (x) characters. The text is padded with text (y), which should normally be a single character.
pad-right ⛔ (x) Int, (y) Text Text Text Pads the input text on the right to a maximum width of (x) characters. The text is padded with text (y), which should normally be a single character.
fmt-float ⛔ (x) Text Float Text Formats the input float per format string (x). The format string is the same as that used by the Delphi Pascal Format function, except that only the e, f, g, m & n value types may be used.
fmt-date ⛔ (x) Text DateTime Text Formats date on input according to format string (x). The format string is the same as that used by the Delphi Pascal DateTimeToString function.
int-to-hex ⛔ (x) Int Int Text Converts input Int to hexadecimal format, with the minimum number of digits specified by (x). Values that are shorter than (x) are left padded with zeros.

Type Conversion Filters

Filter Parameters Input Type Output Type Notes
parse-int ⛔ none Textish Int or Null Parses the input Text as an integer. If the conversion fails then Null is returned.
parse-float ⛔ none Text or Int Float or Null Parses the input as a floating point value. Text input is converted a float if possible, otherwise Null is returned. Int values always converted.
parse-date ⛔ none Textish DateTime or Null Parses the input Text as a DateTime value. If the conversion fails then Null is returned.
parse-bool ⛔ none Any Boolean Parses the input as a Boolean value. Always returns the truthiness value as defined for the input type.
hex-to-int ⛔ none Text Int or Null Converts the input hexadecimal Text into an integer. If the conversion fails then Null is returned.
to-string ⛔ none Any Text Converts any type to Text in the default format for the type.
to-file ⛔ none Text File or Null Converts the input Text value to a File object, providing the input is a valid file path. Null is returned otherwise.
to-dir ⛔ none Text Directory or Null Converts the input Text value to a Directory object, providing the input is a valid directory path. Null is returned otherwise.

Unit Conversion Filters

Filter Parameters Input Type Output Type Notes
c-to-f ⛔ none Int or Float Float Converts the input number from degrees Centigrade to degrees Fahrenheit.
f-to-c ⛔ none Int or Float Float Converts the input number from degrees Fahrenheit to degrees Centigrade.
c-to-k ⛔ none Int or Float Float or Null Converts the input number from degrees Centigrade to Kelvin. If the input value is less than -273.15℃ then Null is returned.
k-to-c ⛔ none Int or Float Float or Null Converts the input number from Kelvin to degrees Centigrade. If the input value is less than 0K then Null is returned.

File Filters

File filters all take a File object as input. They are:

Filter Parameters Input Type Output Type Notes
file-name ⛔ none File Text File name without path.
file-path ⛔ none File Text Full path to file. This is the File default text.
file-dir ⛔ none File Directory Directory containing file.
file-ext ⛔ none File Text File extension, if any.
file-base-name ⛔ none File Text File name without path or extension.
file-mod-date ⛔ none File DateTime Date & time file was last modified.
file-create-date ⛔ none File DateTime Date & time file was created.
file-access-date ⛔ none File DateTime Date & time file was last accessed.

Directory filters

Directory filters all take a Directory object as input. They are:

Filter Parameters Input Type Output Type Notes
dir-name ⛔ none Directory Text Name of directory without path.
dir-path ⛔ none Directory Text Full path to directory. This is the Directory default text.
dir-parent ⛔ none Directory Directory Directory's parent directory. Null if directory has no parent.
dir-mod-date ⛔ none Directory Date Date & time directory was last modified.
dir-create-date ⛔ none Directory Date Date & time directory was created.
dir-access-date ⛔ none Directory Date Date & time directory was last accessed.

Miscellaneous Filters

set-var

⛔ Sets the value of the variable named in the parameter to the value of the filter's input & returns the same value.

If the variable does not exist it is created, otherwise any existing value is overwritten.

The variable name must have a valid name. It must have Text type, for example a quoted string. If an actual, unquoted, variable name is specified then the value, not the name, of that variable will be used as the variable name. Be careful!

To prevent the variable's value from being returned from the placeholder pipe the value to a sink filter.

Parameter: Name of variable, type Text

Input type: anything

Output type: same as input type

Examples:

{{ "Lorem ipsum dolor" > set-var < "foo" > sink }}

Sets variable foo to have value "Lorem ipsum dolor" and returns Null from the placeholder.

{{ "Duis volutpat sapien" > set-var < foo }}

Assuming variable foo has value "bar" then the above placeholder sets the variable bar (not foo) to "Duis volutpat sapien". This time the placeholder also returns "Duis volutpat sapien".

{{ "FA42" > hex-to-int > set-var < "foo" }}

Here set-var gets an Int value from the preceding filter and stores it in variable foo, which will then have type Int. The value is also returned from the placeholder.

sink

⛔ Swallows all its input and returns an empty string. Aimed for use with some special filters that create side affects where no output is required.

Input type: anything

Output type: null


Clone this wiki locally