# Template Filter Guide

# abs

Returns the absolute value of the value.

For example:

{{ "-5"|abs }}
> 5

# add

Adds the first argument to the value. The result depends on the data types.

Examples:

Add an integer to an integer:

{{ "5"|add:"2" }}
> 7

Add two lists together:

{{ "{1,2}"|add:"{3}" }}
> {1,2,3}

Add an element to a list:

{{ "{1,2}"|add:"dog"}
> {1,2,"dog"}

Add seconds to a date:

{{ now|add:"3600" }}
> A date one hour in the future

Concatenating two strings:

{{ "My name is"|add:" Bob" }}
> My name is Bob

# and

# annotate

# apnumber

# args

# attrinfo

# autoformat

# bool

# camelcase

Removes all non-alphanumeric characters from a string and converts the result to CamelCase.

For example:

{{ "My name is Bob"|camelcase }}
>MyNameIsBob

# camelcasereverse

Inserts spaces into a CamelCase string. For example:

{{ "MyNameIsBob"|camelcasereverse }}
> My Name Is Bob

# categoryinfo

# categoryvalue

# children

For a value that represents a DTree node, the children filter returns an Iterator with the child objects of a node.

The input value can be a DataID, nodeRec, nickname, DAPINODE, or RHNode.

For example, to list the contents of the Enterprise Workspace:

{% for child in "2000"|children %}
	{{ child.name }}<br />
{% endfor %}

Behind the scenes this calls the llnode.NodeListContents() on the node.

# compact

# compress

Replaces all sequences of one or more spaces or tabs to a single space character. For example:

{{ "Hello    world!"|compress }}
> Hello world!

# count

Returns the length of the value. The filter can be applied to a String, List, RecArray, or any other iterable RHObject subclass.

# customcolumn

# datatype

Returns the data type of the value as a string.

For example:

{{ "5"|datatype }}
> string

{{ 5|datatype }}
> integer

# date

Used to format a date. The filter accepts a format parameter that defines how the date should be formatted. The keyword 'long' or 'short' formats the date according to the user's locale and system settings, but these can be more strictly defined with the values in the translation table below. The formatter defaults to 'short' when the parameter is omitted.

Examples: {{ now|date:"long" }} > (output will depend on the system configuration, > but will include the date and time) {# these are synonymous #} {{ now|date }} {{ now|date:"short" }} > (output will depend on the system configuration, > but will include just the date)

{# or, use a custom date mask #}
{{ now|date:"%Y-%m-%d" }}
> 2013-02-01

If you will be using the same format multiple times within the same template, then it might make sense to set a context variable with the format.

{% set "%Y-%m-%d" as mydateformat %}

{{ date1|date:mydateformat }}
{{ date2|date:mydateformat }}
{{ date3|date:mydateformat }}

The date mask values are as follows:

Value Description
%% A percentage sign
%a The three-character abbreviated weekday name (e.g., Mon, Tue, etc.)
%b The three-character abbreviated month name (e.g., Jan, Feb, etc.)
%d The two-digit day of the month, from 01 to 31 (e.g., 01-31)
%j The three-digit day of year, from 001 through 366
%m The two-digit month (e.g., 01-12)
%p AM or PM
%w The 1-digit weekday, from 1 through 7, where 1= Sunday
%y The two-digit year (e.g., 93)
%A The full weekday name (e.g., Monday)
%B The full month name (e.g., January)
%H The two-digit hour on a 24-hour clock, from 00 to 23
%I The two-digit hour, from 01 through 12
%M The minutes past the hour, from 00 to 59
%P AD or BC
%S The seconds past the minute, from 00 to 59
%Y The year, including the century (e.g., 1993)

# dateonly

# daterelative

# dayssince

# debug

# decode

Compares the value to each argument. If an equal match is found it returns the following argument. If no match is found then Undefined is returned. This filter is analogous to the DECODE SQL expression in Oracle.

For example:

{{ "2"|decode:"1":"one":"2":"two":"3":"three" }}
> two

# decodeurl

# default

The default filter is a conditional statement that returns the first argument if the input resolves to false. See the if template tag on how single expressions are resolved. The first argument defaults to an empty string if ommitted.

For example:

{{ value|default:"value resolve to false, so output this instead" }}

This is equivalent to:

{% if not value %}
	value resolve to false, so output this instead
{% endfor %}

# default_if_undefined

The default_if_undefined filter is a conditional statement that returns the first argument if the input is Undefined. See the default template tag for an example.

# docs

For a value that is an RHObject, this filter extracts the internal documentation of an accessor method on the object.

For example:

Say we have an RHNode variable. To extract the documentation of the children accessor method:

{{ node|docs:"children" }}
>> Returns an Iterator containing the children nodes.

# each

Apply a filter to each element of a List.

For example:

{{ "{1,2,3}"|each:"add":10 }}
> {11,12,13}

# em

Wraps the value in <em></em> tags.

For example:

My name is {{ "Bob"|em }}.
> My name is <em>Bob</em>.

# encodeurl

# escape

See escapehtml.

# escapehtml

Escapes a string to HTML format.

Example:

{{ "<p>paragraph</p>"|escapehtml }}

This would return &lt;p&gt;paragraph&lt;/p&gt;.

# escapejs

# escapeurl

# escapexml

# execute

# facetfilter

# facets

# fieldnames

# filename

# filepath

# filesizeformat

# filter

# filterattribute

# formfield

The formfield filter wraps a value in an HTML form field. For example:

{{ "initial value"|formfield:"StringFormField":"myfield" }}

This would return:

<input type="text" id="id_rhmyfield" name="rhmyfield" value="initial value" size="40">

TODO: This list is wrong. We need to list widgets, not form fields.

A number of form field types are supported, including:

  • CheckboxFormField
  • DateTimeFormField
  • DateFormField
  • FileFormField
  • HiddenFormField
  • IntegerFormField
  • DTreeFormField
  • KUAFFormField
  • SelectFormField
  • RadioFormField
  • StringFormField
  • PasswordFormField
  • TextFormField

# formfieldsetattr

The formfield filter wraps a value in an HTML form field. For example:

{{ "initial value"|formfield:"StringFormField":"myfield" }}

This would return:

<input type="text" id="id_rhmyfield" name="rhmyfield" value="initial value" size="40">

TODO: This list is wrong. We need to list widgets, not form fields.

A number of form field types are supported, including:

  • CheckboxFormField
  • DateTimeFormField
  • DateFormField
  • FileFormField
  • HiddenFormField
  • IntegerFormField
  • DTreeFormField
  • KUAFFormField
  • SelectFormField
  • RadioFormField
  • StringFormField
  • PasswordFormField
  • TextFormField

# formfieldsetplaceholder

The formfield filter wraps a value in an HTML form field. For example:

{{ "initial value"|formfield:"StringFormField":"myfield" }}

This would return:

<input type="text" id="id_rhmyfield" name="rhmyfield" value="initial value" size="40">

TODO: This list is wrong. We need to list widgets, not form fields.

A number of form field types are supported, including:

  • CheckboxFormField
  • DateTimeFormField
  • DateFormField
  • FileFormField
  • HiddenFormField
  • IntegerFormField
  • DTreeFormField
  • KUAFFormField
  • SelectFormField
  • RadioFormField
  • StringFormField
  • PasswordFormField
  • TextFormField

# formfieldsetrequired

The formfield filter wraps a value in an HTML form field. For example:

{{ "initial value"|formfield:"StringFormField":"myfield" }}

This would return:

<input type="text" id="id_rhmyfield" name="rhmyfield" value="initial value" size="40">

TODO: This list is wrong. We need to list widgets, not form fields.

A number of form field types are supported, including:

  • CheckboxFormField
  • DateTimeFormField
  • DateFormField
  • FileFormField
  • HiddenFormField
  • IntegerFormField
  • DTreeFormField
  • KUAFFormField
  • SelectFormField
  • RadioFormField
  • StringFormField
  • PasswordFormField
  • TextFormField

# fromjson

# functionmenu

# get

# hash

# hasversion

# helpurl

# hide

# htmlify

# humanizelist

# img

# img32

# indexof

# intcomma

# ismember

# ismoduleinstalled

# iterator

# join

Accepts a List and concatenates the elements together into a string. The filter accepts an optional delimiter parameter, which defaults to an empty string if omitted.

Example:

{% set "{1,2,3}"|list as mylist %}

{{ mylist|join:", " }}
> 1, 2, 3

# jstring

# keypath

# keys

# length

Returns the length of the value. The filter can be applied to a String, List, RecArray, or any other iterable RHObject subclass.

Create a link to a Content Server node.

Up to four parameters are supported. All parameters are optional:

{{ <dataid>|link:<command>:<linkText>:<disabledLink>:<version> }}

The parameters are as follows:

  • <dataid> - A DataID, RHNode, or nickname of a Content Server node.
  • <command> - The name of the command. Default: "open".
  • <linkText> - The link text. Default: The name of the command, unless "open" where it default to the name of the node.
  • <disabledLink> - A boolean to determine whether disabled links should be displayed. Default: false.
  • <version> - The version number for URLs that require it.

# list

Converts the given value to a List, if possible.

Example:

{% set "{1,2,3}"|list as mylist %}

# listfilter

# listify

# livereport

# llcache

Cache or fetch a value from the Content Server LLCache table. The filter accepts no parameters and its behaviour will depend on the data type of the value. If the value is not an integer the value will be cached and an integer key will be returned. If the value is an integer then it will be used to fetch the cached value.

For example:

{{ "My name is Chris"|llcache }}
> returns a cache id e.g., 123456789

To fetch the results:

{{ 123456789|llcache }}
> "My name is Chris"

A few notes:

  • Integer, Object, and Frame types cannot be cached; and
  • cached values expire according to the CacheKeepMinutes parameter in the opentext.ini file. By default this is three days.

# lower

Converts a string to lowercase.

Example:

My name is {{ "John"|lower }}
> My name is john.

# markdown

# matchbetween

# modelget

# modelset

# modimg

# multiply

# node

Returns an RHNode.

# nodeversion

Returns an RHNode.

# noop

# or

# paginate

# paginator

# parsecsv

Parses a string with comma separated values and returns the result as a list of lists.

The outer list contains the row values while the inner lists contain the column values. Entries may be enclosed in single or double quotes, and these can be optionally removed by passing true to the filter.

For example:

{# unescapejson used to convert \n to proper EOL character #}
{{ 'a,b,c\nd,e,f\ng,h,"value1, value2"'|unescapejson|csv:true }}

This returns:

{{'a','b','c'},{'d','e','f'},{'g','h','value1, value2'}}.

# parsetsv

Identical to parsecsv, except delimits by the tab character.

# pluck

# pluralize

Returns a plural suffix if the value is not 1. The default suffix is 's'.

Examples:

This folder contains {{ itemcount }} item{{ itemcount|pluralize }}.

This will return "This folder contains 1 item." or "This folder contains 3 items." depending on the value of itemcount.

Alternate suffixes can also be used:

This room contains {{ itemcount }} box{{ itemcount|pluralize:"es" }}.

Irregular endings are also supported:

This topic has {{ replycount }} repl{{ replycount|pluralize:"ies":"y" }}.

# precache

# precacherelated

# pref

# querystring

# quote

Adds quotes around the value.

For example:

{{ 'My name is Bob'|quote }}
> "My name is Bob"

Double quotes are used by default, but can be controlled with a parameter:

{{ 'My Name is Bob'|quote:"'" }}
> 'My name is Bob'

# range

# readinggroupname

# remove

Remove one or more values from a list. For example:

{{ [1,2,3]|remove:3:1 }}
> {2}

Create a link to a Content Server node.

Up to four parameters are supported. All parameters are optional:

{{ <dataid>|link:<command>:<linkText>:<disabledLink>:<version> }}

The parameters are as follows:

  • <dataid> - A DataID, RHNode, or nickname of a Content Server node.
  • <command> - The name of the command. Default: "open".
  • <linkText> - The link text. Default: The name of the command, unless "open" where it default to the name of the node.
  • <disabledLink> - A boolean to determine whether disabled links should be displayed. Default: false.
  • <version> - The version number for URLs that require it.

# repeat

Outputs the value multiple times according to the first parameter.

For example:

{{ "abc"|repeat:3 }}
> abcabcabc

# replace

Replaces all string instances of the first parameter with the second parameter.

For example:

{{ "My name is Bob"|replace:"Bob":"Chris" }}
> My name is Chris

# round

# runreport

# scriptnode

# securetoken

Generates a secure request token. The value defines for which action the token should apply (deprecated in CS10.5).

For example:

{{ "textedit"|securetoken }}
> MGcZQa/s4T9n8f4mOWmrNlIF4+cI1MWOEWMCFvApLNI=

To create a hidden form element:

{{ "textedit"|securetoken|formfield:"hidden":"secureRequestToken" }}
> <input type="hidden" id="id_secureRequestToken" name="secureRequestToken" value="MGcZQa/s4T9n8f4mOWmrNlIF4+cI1MWOEWMCFvApLNI=" />

# selectrelated

# setassoc

# sibling

# slice

# snapshot

# sort

The sort filter is used to sort a RecArray, List, or Iterable object. The behaviour depends on the input.

# split

# strformat

# string

# stripeols

# striphtml

Strip all HTML tags from the string.

For example:

{{ "<strong>Bold</strong> <a href="#abc">Some link</a>"|striphtml }}
> Bold Some link

# strong

Wraps the value in <strong></strong> tags.

For example:

My name is {{ "Bob"|strong }}.
> My name is <strong>Bob</strong>.

# suffix

# sum

# ternary

The ternary filter is conditional statement of the following form:

{{ condition|ternary:"value1":"value2" }}

This is functionally equivalent to:

{% if condition %}
	value1
{% else %}
	value2
{% endif %}

The second argument is optional and defaults to an empty string if omitted.

# timesince

# title

Capatalizes the first letter of each word. The subsequent letters in each word are converted to lowercase.

For example:

{{ "my naME is bOb"|title }}
> My Name Is Bob

# tocsv

# todate

# toexcel

# tojson

# trans

# trim

# truncatechars

# unescapehtml

# unescapejson

# union

# unquote

# upper

Converts a string to uppercase.

For example:

My name is {{ "John"|upper }}.
> My name is JOHN.

# url

# urlize

# usemacro

# user

# validvalues

# values

For a value that represents an Assoc or a Record, this filter returns the values of the structure as a List.

# valueslist

# version

# versionnum

# webreport

# weekdayssince

Create a link to a Content Server node.

Up to four parameters are supported. All parameters are optional:

{{ <dataid>|link:<command>:<linkText>:<disabledLink>:<version> }}

The parameters are as follows:

  • <dataid> - A DataID, RHNode, or nickname of a Content Server node.
  • <command> - The name of the command. Default: "open".
  • <linkText> - The link text. Default: The name of the command, unless "open" where it default to the name of the node.
  • <disabledLink> - A boolean to determine whether disabled links should be displayed. Default: false.
  • <version> - The version number for URLs that require it.

# wordmlify

# work

# xlate

Last Updated: 8/13/2024, 10:33:01 AM