Module erlydtl_filters

Template filters.

Copyright © 2008 Roberto Saccon, Evan Miller

Introduced in: 2007-11-11 by Roberto Saccon, Evan Miller -------------------------------------------------------------------

Authors: Roberto Saccon (rsaccon@gmail.com) [web site: http://rsaccon.com], Evan Miller (emmiller@gmail.com).

Description

Template filters

Function Index

add/2Adds to values.
addDefaultURI/1
addslashes/1Adds slashes before quotes.
capfirst/1Capitalizes the first character of the value.
cast_to_float/1
cast_to_integer/1
center/2Centers the value in a field of a given width.
cut/2Removes all values of arg from the given string.
date/1Formats a date according to the default format.
date/2Formats a date according to the given format.
date/3Formats a date according to the default format localizing it with provided translation function.
date/4
default/2If value evaluates to false, use given default.
default_if_none/2If (and only if) value is undefined, use given default.
dictsort/2Takes a list of dictionaries or proplists and returns that list sorted by the key given in the argument.
dictsortreversed/2Same as dictsort, but the list is reversed.
divisibleby/2Returns true if the value is divisible by the argument.
escapejs/1Escapes characters for use in JavaScript strings.
filesizeformat/1Format the value like a human-readable file size.
first/1Returns the first item in a list.
fix_ampersands/1Replaces ampersands with & entities.
floatformat/1When used without an argument, rounds a floating-point number to one decimal place -- but only if there's a decimal part to be displayed.
floatformat/2
force_escape/1Applies HTML escaping to a string.
format_integer/1
format_number/1
get_digit/2Given a whole number, returns the requested digit, where 1 is the right-most digit.
iriencode/1
join/2Joins a list with a given separator.
last/1Returns the last item in a list.
length/1Returns the length of the value.
length_is/2Returns True iff the value's length is the argument.
linebreaks/1Replaces line breaks in plain text with appropriate HTML.
linebreaksbr/1Converts all newlines to HTML line breaks.
linenumbers/1Displays text with line numbers.
ljust/2Left-aligns the value in a field of a given width.
lower/1Converts a string into all lowercase.
make_list/1Returns the value turned into a list.
phone2numeric/1Converts a phone number (possibly containing letters) to its numerical equivalent.
pluralize/1
pluralize/2Returns a plural suffix if the value is not 1.
pprint/1"pretty print" arbitrary data structures.
random/1Returns a random item from the given list.
random_num/1
random_range/1
removetags/2
rjust/2Right-aligns the value in a field of a given width.
round/2
slice/2Returns a slice of the list.
slugify/1Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens.
stringformat/2Returns a formatted string.
stringformat_io/7 A conversion specifier contains two or more characters and has the following components, which must occur in this order:.
striptags/1Strips all [X]HTML tags.
time/1Formats a time according to the given format.
time/2
timesince/1
timesince/2
timeuntil/1
timeuntil/2
title/1Converts a string into titlecase.
truncatechars/2Truncates a string after a certain number of characters.
truncatewords/2Truncates a string after a certain number of words.
truncatewords_html/2Similar to truncatewords, except that it is aware of HTML tags.
unjoin/2
unordered_list/1Recursively takes a self-nested list and returns an HTML unordered list -- WITHOUT opening and closing <ul> tags.
upper/1Converts a string into all uppercase.
urlencode/1Escapes a value for use in a URL.
urlencode/2
urlize/1Converts URLs in text into clickable links.
urlize/2
urlizetrunc/2Converts URLs into clickable links just like urlize, but truncates URLs longer than the given character limit.
wordcount/1Returns the number of words.
wordwrap/2Wraps words at specified line length, uses <BR/> html tag to delimit lines.
yesno/2Given a string mapping values for true, false and (optionally) undefined, returns one of those strings according to the value.

Function Details

add/2

add(LHS, RHS) -> any()

Adds to values

addDefaultURI/1

addDefaultURI(Domain) -> any()

addslashes/1

addslashes(Input) -> any()

Adds slashes before quotes.

capfirst/1

capfirst(T) -> any()

Capitalizes the first character of the value.

cast_to_float/1

cast_to_float(Input) -> any()

cast_to_integer/1

cast_to_integer(Input) -> any()

center/2

center(Input, Number) -> any()

Centers the value in a field of a given width.

cut/2

cut(Input, Arg) -> any()

Removes all values of arg from the given string.

date/1

date(Input) -> any()

Formats a date according to the default format.

date/2

date(Input, FormatStr) -> any()

Formats a date according to the given format.

date/3

date(Input, TransFun, Locale) -> any()

Formats a date according to the default format localizing it with provided translation function.

date/4

date(Input, FormatStr, TransFun, Locale) -> any()

default/2

default(Input, Default) -> any()

If value evaluates to false, use given default. Otherwise, use the value.

default_if_none/2

default_if_none(Input, Default) -> any()

If (and only if) value is undefined, use given default. Otherwise, use the value.

dictsort/2

dictsort(DictList, Key) -> any()

Takes a list of dictionaries or proplists and returns that list sorted by the key given in the argument.

dictsortreversed/2

dictsortreversed(DictList, Key) -> any()

Same as dictsort, but the list is reversed.

divisibleby/2

divisibleby(Input, Divisor) -> any()

Returns true if the value is divisible by the argument.

escapejs/1

escapejs(Input) -> any()

Escapes characters for use in JavaScript strings.

filesizeformat/1

filesizeformat(Input) -> any()

Format the value like a human-readable file size.

first/1

first(Rest) -> any()

Returns the first item in a list.

fix_ampersands/1

fix_ampersands(Input) -> any()

Replaces ampersands with & entities.

floatformat/1

floatformat(Number) -> any()

When used without an argument, rounds a floating-point number to one decimal place -- but only if there's a decimal part to be displayed

floatformat/2

floatformat(Number, Place) -> any()

force_escape/1

force_escape(Input) -> any()

Applies HTML escaping to a string.

format_integer/1

format_integer(Input) -> any()

format_number/1

format_number(Input) -> any()

get_digit/2

get_digit(Input, Digit) -> any()

Given a whole number, returns the requested digit, where 1 is the right-most digit.

iriencode/1

iriencode(Input) -> any()

join/2

join(Input, Separator) -> any()

Joins a list with a given separator.

last/1

last(Input) -> any()

Returns the last item in a list.

length/1

length(Input) -> any()

Returns the length of the value.

length_is/2

length_is(Input, Number) -> any()

Returns True iff the value's length is the argument.

linebreaks/1

linebreaks(Input) -> any()

Replaces line breaks in plain text with appropriate HTML

linebreaksbr/1

linebreaksbr(Input) -> any()

Converts all newlines to HTML line breaks.

linenumbers/1

linenumbers(Input) -> any()

Displays text with line numbers.

ljust/2

ljust(Input, Number) -> any()

Left-aligns the value in a field of a given width.

lower/1

lower(Input) -> any()

Converts a string into all lowercase.

make_list/1

make_list(Input) -> any()

Returns the value turned into a list. For an integer, it's a list of digits. For a string, it's a list of characters. Added this for DTL compatibility, but since strings are lists in Erlang, no need for this.

phone2numeric/1

phone2numeric(Input) -> any()

Converts a phone number (possibly containing letters) to its numerical equivalent.

pluralize/1

pluralize(Number) -> any()

pluralize/2

pluralize(Number, Suffix) -> any()

Returns a plural suffix if the value is not 1. By default, this suffix is 's'.

pprint/1

pprint(Input) -> any()

"pretty print" arbitrary data structures. Used for debugging.

random/1

random(Input) -> any()

Returns a random item from the given list.

random_num/1

random_num(Value) -> any()

random_range/1

random_range(Range) -> any()

removetags/2

removetags(Input, Tags) -> any()

rjust/2

rjust(Input, Number) -> any()

Right-aligns the value in a field of a given width.

round/2

round(Number, Precision) -> any()

slice/2

slice(Input, Index) -> any()

Returns a slice of the list.

slugify/1

slugify(Input) -> any()

Converts to lowercase, removes non-word characters (alphanumerics and underscores) and converts spaces to hyphens.

stringformat/2

stringformat(Input, Conversion) -> any()

Returns a formatted string

stringformat_io/7

stringformat_io(Input, Conversion, ConversionFlag, MinFieldWidth, Precision, PrecisionLength, X7) -> any()

A conversion specifier contains two or more characters and has the following components, which must occur in this order:

1. The "%" character, which marks the start of the specifier. 2. Mapping key (optional), consisting of a parenthesised sequence of characters (for example, (somename)). 3. Conversion flags (optional), which affect the result of some conversion types. 4. Minimum field width (optional). If specified as an "*" (asterisk), the actual width is read from the next element of the tuple in values, and the object to convert comes after the minimum field width and optional precision. 5. Precision (optional), given as a "." (dot) followed by the precision. If specified as "*" (an asterisk), the actual width is read from the next element of the tuple in values, and the value to convert comes after the precision. 6. Length modifier (optional). 7. Conversion type.

striptags/1

striptags(Input) -> any()

Strips all [X]HTML tags.

time/1

time(Input) -> any()

Formats a time according to the given format.

time/2

time(Input, FormatStr) -> any()

timesince/1

timesince(Date) -> any()

timesince/2

timesince(Date, Comparison) -> any()

timeuntil/1

timeuntil(Date) -> any()

timeuntil/2

timeuntil(Date, Comparison) -> any()

title/1

title(Input) -> any()

Converts a string into titlecase.

truncatechars/2

truncatechars(Input, Max) -> any()

Truncates a string after a certain number of characters.

truncatewords/2

truncatewords(Input, Max) -> any()

Truncates a string after a certain number of words.

truncatewords_html/2

truncatewords_html(Input, Max) -> any()

Similar to truncatewords, except that it is aware of HTML tags.

unjoin/2

unjoin(String, L) -> any()

unordered_list/1

unordered_list(List) -> any()

Recursively takes a self-nested list and returns an HTML unordered list -- WITHOUT opening and closing <ul> tags.

upper/1

upper(Input) -> any()

Converts a string into all uppercase.

urlencode/1

urlencode(Input) -> any()

Escapes a value for use in a URL.

urlencode/2

urlencode(Input, Safe) -> any()

urlize/1

urlize(Input) -> any()

Converts URLs in text into clickable links.

urlize/2

urlize(Input, Trunc) -> any()

urlizetrunc/2

urlizetrunc(Input, Trunc) -> any()

Converts URLs into clickable links just like urlize, but truncates URLs longer than the given character limit.

wordcount/1

wordcount(Input) -> any()

Returns the number of words.

wordwrap/2

wordwrap(Input, Number) -> any()

Wraps words at specified line length, uses <BR/> html tag to delimit lines

yesno/2

yesno(Bool, Choices) -> any()

Given a string mapping values for true, false and (optionally) undefined, returns one of those strings according to the value.


Generated by EDoc