Skip to main content

Expression Syntax

Whenever specifying placeholders, binding variables, using intrinsic expression-attributes or binding dynamic values to the attributes of tags, expressions are the means via which to describe the value used; they can be as simple as accessing a variable, stringing data together or computing a numeric value and may become as nuanced as using boolean logic, providing fallback-values or accessing members of a variable.

String Literals

A string represents a sequence of characters as-is, to be used in expressions; their contents are delimited by single-quotes (Code-Blocks are only available within the browser) or, alternatively, double-quotes (Code-Blocks are only available within the browser).

Code-Blocks are only available within the browser

In order to include a literal single-quote, prepend it by a backslash (Code-Blocks are only available within the browser) in order to avoid premature string termination.

Code-Blocks are only available within the browser
tip

When specifying string-literals inside of attribute-values which themselves use string-notation delimited by a double-quote (Code-Blocks are only available within the browser), said double-quotes are to be marked by a preceding backslash (Code-Blocks are only available within the browser) in order to avoid premature attribute-value termination.

Code-Blocks are only available within the browser

Numbers

Numeric values are always expressed using the decimal system, i.e. digits Code-Blocks are only available within the browser through Code-Blocks are only available within the browser.

Code-Blocks are only available within the browser

Fractional values may be depicted using the decimal-dot (Code-Blocks are only available within the browser).

Code-Blocks are only available within the browser

Where the leading zero can be dropped entirely:

Code-Blocks are only available within the browser

Additionally, numbers may become negative simply by prepending a minus-sign (Code-Blocks are only available within the browser).

Code-Blocks are only available within the browser Code-Blocks are only available within the browser

Concatenation Operator

Due to this syntax being dynamically typed, the addition-operator (Code-Blocks are only available within the browser) cannot reliably be overloaded to concatenate values back-to-back into a resulting string; thus, the ampersand (Code-Blocks are only available within the browser) is used to denote this intent.

Assuming that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser and Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, the expression

Code-Blocks are only available within the browser

will result in

Code-Blocks are only available within the browser

String-Interpolation

As the concatenation-operator Code-Blocks are only available within the browser tends to clutter the expression whenever multi-part strings are built, string-interpolation poses an elegant alternative, increasing readability.

Instead of writing

Code-Blocks are only available within the browser

one may simply employ the template-literal, which works analogous to strings, just that it uses backticks (Code-Blocks are only available within the browser) as quotes and enables interpolation-syntax analogous to how it can be used all throughout markup plain-text:

Code-Blocks are only available within the browser

Interpolations may be nested to any arbitrary depth, whenever necessary (the following example is just for shows and would never make sense in the field):

Code-Blocks are only available within the browser

In order to have literal curly-brackets be contained in a template-literal, simply prepend them by a backslash, as follows:

Code-Blocks are only available within the browser

Mathematical Operators

The following mathematical operators are available when formulae are to be expressed. The operator of highest precedence will be evaluated first - use parentheses when necessary.

OperationOperatorPrecedence
AdditionCode-Blocks are only available within the browser1
SubtractionCode-Blocks are only available within the browser1
MultiplicationCode-Blocks are only available within the browser2
DivisionCode-Blocks are only available within the browser2
ModuloCode-Blocks are only available within the browser2
ExponentiationCode-Blocks are only available within the browser3

Numeric Operators

Due to the fact that the precision of numbers is widened as required, multiplying a long (whole number) by a double (fractional number) will convert the former to the latter and thus result in a fractional value. When working with literal values, like Code-Blocks are only available within the browser and Code-Blocks are only available within the browser, one can always force fractional evaluation by adding a simple Code-Blocks are only available within the browser to one of the two operands, as in Code-Blocks are only available within the browser - now, the result will become Code-Blocks are only available within the browser instead of Code-Blocks are only available within the browser. If both operands are represented by variables or other complex expressions though, this little trick will not be applicable: that's when one must employ the following numeric operators.

To Long

Converts a fractional number to a whole number by disregarding its fractional part, while passing whole numbers through untouched; let's assume that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, then

Code-Blocks are only available within the browser

will result in Code-Blocks are only available within the browser.

To Double

Converts a whole number to a fractional number by introducing a zero-valued fractional part, while passing fractional numbers through untouched; let's assume that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, then

Code-Blocks are only available within the browser

will result in Code-Blocks are only available within the browser.

Utilities

Round

Rounds any given number to the nearest whole value, meaning that a fractional part of greater than or equal to one-half will round up, while everything else will round down; passes whole numbers through untouched; let's assume that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, then

Code-Blocks are only available within the browser

will result in Code-Blocks are only available within the browser, while a value of Code-Blocks are only available within the browser would result in Code-Blocks are only available within the browser.

Floor

Sets the fractional part of any number to zero, effectively disregarding it; passes whole numbers through untouched; let's assume that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, then

Code-Blocks are only available within the browser

will result in Code-Blocks are only available within the browser.

Ceil

Sets the fractional part of any number to zero, effectively disregarding it, and increments its whole part by one if the fractional part was non-zero; passes whole numbers through untouched; let's assume that Code-Blocks are only available within the browser holds Code-Blocks are only available within the browser, then

Code-Blocks are only available within the browser

will result in Code-Blocks are only available within the browser.

Min

Yields the smallest value of a number of provided inputs, where individual values are comma-separated.

Code-Blocks are only available within the browser

The above will result in Code-Blocks are only available within the browser.

Max

Yields the largest value of a number of provided inputs, where individual values are comma-separated.

Code-Blocks are only available within the browser

The above will result in Code-Blocks are only available within the browser.

Sum

Sums up all provided inputs, where individual values are comma-separated.

Code-Blocks are only available within the browser

The above will result in Code-Blocks are only available within the browser.

Avg

Calculates the level term, also known as average, of all provided inputs, where individual values are comma-separated.

Code-Blocks are only available within the browser

The above will result in Code-Blocks are only available within the browser.

String Transformation

The following transformations may come in handy when dealing with strings of characters that are to be normalised in one form or another; operators are chainable, allowing to combine effects. Let's assume an input of Code-Blocks are only available within the browser being Code-Blocks are only available within the browser.

OperationOperatorResult
UppercaseCode-Blocks are only available within the browserCode-Blocks are only available within the browser
LowercaseCode-Blocks are only available within the browserCode-Blocks are only available within the browser
TitlecaseCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Toggle CasingCode-Blocks are only available within the browserCode-Blocks are only available within the browser
SlugifyCode-Blocks are only available within the browserCode-Blocks are only available within the browser
AsciifyCode-Blocks are only available within the browserCode-Blocks are only available within the browser
TrimCode-Blocks are only available within the browserCode-Blocks are only available within the browser
ReverseCode-Blocks are only available within the browserCode-Blocks are only available within the browser

In order to asciify, slugify and trim, use Code-Blocks are only available within the browser, which is resulting in Code-Blocks are only available within the browser.

Immediate Array

Whenever static array of items are to be instantiated for further use, simply specify the desired items in a comma-separated (Code-Blocks are only available within the browser) list, enclosed by square brackets (Code-Blocks are only available within the browser).

Code-Blocks are only available within the browser

This notation may especially come in handy when combined with the intrinsic Code-Blocks are only available within the browser-attribute:

Code-Blocks are only available within the browser

Items may also once again be lists themselves, allowing for a tuple-style dataset.

Code-Blocks are only available within the browser

And thereby give rise to more advanced concepts of templating.

Code-Blocks are only available within the browser

Immediate Map

Whenever static maps of key-value pairs are to be instantiated for further use, simply specify the desired items in a comma-separated (Code-Blocks are only available within the browser) list, enclosed by curly brackets (Code-Blocks are only available within the browser). If the value of a key is to be equal the value of a variable of the same name, said value may be omitted.

Code-Blocks are only available within the browser

Analogous to immediate arrays, immediate maps may also be combined with the intrinsic Code-Blocks are only available within the browser-attribute, where loops will always iterate the keys of maps, as follows:

Code-Blocks are only available within the browser

Range Operator

In order to quickly generate a list containing a subsequent sequence of numbers, the range operator may be used, with both bounds being inclusive.

Code-Blocks are only available within the browser

is thereby equivalent to

Code-Blocks are only available within the browser

This operator may especially come in handy when combined with the intrinsic Code-Blocks are only available within the browser attribute.

Code-Blocks are only available within the browser

Substring Operator

A substring represents a sub-sequence of characters within another string; it may span only a single character, a few or up to the whole input, based on the colon-separated (Code-Blocks are only available within the browser) start- and end-indices, which are both inclusive and start at 0.

Given an Code-Blocks are only available within the browser of Code-Blocks are only available within the browser with the following indices

Negative IndexCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Positive IndexCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
LetterCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser

Whenever indices are negative, they simply wrap around the very beginning at Code-Blocks are only available within the browser, counting characters back-to-start; this may be useful to operate on strings of unknown length. Next up, instead of numeric indices, strings marking positions within the input may also be provided - if they do not occur, the fallback used is either the first- or last character-index, for start and end respectively.

Let's look at some example-operations:

OperationResult
Code-Blocks are only available within the browser
Code-Blocks are only available within the browser
Code-Blocks are only available within the browser
Code-Blocks are only available within the browser
Code-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

String-Split Operator

Whenever a sequence of characters is to be split up into sub-sequences based on a pattern of delimiters, the string-split operator can be used to do so. Let's assume an Code-Blocks are only available within the browser of Code-Blocks are only available within the browser and firstly focus on separators that are either Code-Blocks are only available within the browser or empty - they split each single character up, such that Code-Blocks are only available within the browser and Code-Blocks are only available within the browser both yield:

Code-Blocks are only available within the browser

Specifying delimiters will yield the according sub-sequences:

OperationResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

In order to make use of regular expressions to split on a pattern of delimiters, simply specify the operator Code-Blocks are only available within the browser (regex-split) instead:

Code-Blocks are only available within the browser

will yield

Code-Blocks are only available within the browser

Repeat Operator

Whenever a sequence of characters is to be repeated a certain number of times by simply joining it back-to-back with itself, the repeat-operator allows to depict such behaviour. Let's assume an Code-Blocks are only available within the browser of Code-Blocks are only available within the browser, then the following output-table applies:

OperationResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

This operator may especially come in handy when generating spacers.

Code-Blocks are only available within the browser

Literals

Literals are reserved names, not able to be used as variables, holding a static value:

  • Boolean value of 1, i.e. "yes": Code-Blocks are only available within the browser
  • Boolean value of 0, i.e. "no": Code-Blocks are only available within the browser
  • The absence of a value: Code-Blocks are only available within the browser

Accessing Variables

All variables used in expressions adhere to the convention of Code-Blocks are only available within the browser and simply by specifying their name, their corresponding value will be substituted at the stage of evaluation.

Code-Blocks are only available within the browser

Accessing Members

Variables are not required to hold mere scalar values, e.g. numbers, booleans, strings, etc., but may just as well be lists containing multiple items, maps containing multiple key-value pairs, or objects which contain named fields.

List-Items

Assuming that Code-Blocks are only available within the browser is a collection of individual items, say Code-Blocks are only available within the browser, Code-Blocks are only available within the browser and Code-Blocks are only available within the browser, their indices are simply represented by an ascending numeric index starting at zero. The index may be derived by the value of a variable, interpreted as a number.

Code-Blocks are only available within the browser
my_indexResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Indices can also be specified immediately, with

Code-Blocks are only available within the browser

resulting in Code-Blocks are only available within the browser.

Analogous to bounds on substrings, list-indices may also be negative, meaning that they access elements relative to the back of the sequence, with Code-Blocks are only available within the browser being the last, Code-Blocks are only available within the browser the second to last, etc.

my_indexResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Map-Values

Assuming that Code-Blocks are only available within the browser is assigning keys representing usernames to values being their statistics, say Code-Blocks are only available within the browser -> Code-Blocks are only available within the browser, Code-Blocks are only available within the browser -> Code-Blocks are only available within the browser and Code-Blocks are only available within the browser -> Code-Blocks are only available within the browser, the value of each such key may be accessed by specifying it analogously to numeric indices on lists.

Code-Blocks are only available within the browser
my_keyResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Keys may also be specified immediately, with

Code-Blocks are only available within the browser

resulting in Code-Blocks are only available within the browser.

Object-properties

Assuming that Code-Blocks are only available within the browser is a Java-object containing a few members, say

Code-Blocks are only available within the browser

the value of each member may be accessed by appending a dot (Code-Blocks are only available within the browser), followed by its name.

Code-Blocks are only available within the browser
ExpressionResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Analogously to maps, keys may also be specified dynamically, with

Code-Blocks are only available within the browser

or even immediately, using

Code-Blocks are only available within the browser

resulting in Code-Blocks are only available within the browser.

info

When programming in Java, the established naming-convention regarding properties is Code-Blocks are only available within the browser; as to avoid programmers from being forced to employ Code-Blocks are only available within the browser on objects they want to make accessible within templates, name-conversion occurs automatically, e.g. Code-Blocks are only available within the browser becomes Code-Blocks are only available within the browser.

Boolean Logic

Not (Invert)

By prepending an expression with the Code-Blocks are only available within the browser operator, it's value is interpreted as a boolean and will be inverted, meaning that Code-Blocks are only available within the browser will become Code-Blocks are only available within the browser and vice-versa.

Code-Blocks are only available within the browser
valueResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Or (Disjunction)

By stringing two expressions together using the Code-Blocks are only available within the browser operator, both the left- and the right hand side will be interpreted as boolean values; given that any one of them is Code-Blocks are only available within the browser, the result will be also - otherwise, Code-Blocks are only available within the browser will be the result.

Code-Blocks are only available within the browser
lhsrhsResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser

And (Conjunction)

By stringing two expressions together using the Code-Blocks are only available within the browser operator, both the left- and the right hand side will be interpreted as boolean values; given that both are Code-Blocks are only available within the browser, the result will be also - otherwise, Code-Blocks are only available within the browser will be the result.

Code-Blocks are only available within the browser
lhsrhsResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browserCode-Blocks are only available within the browser

Branching

If an expression is to be selected out of two branches, one for Code-Blocks are only available within the browser and one for Code-Blocks are only available within the browser, given a boolean input, Code-Blocks are only available within the browser/Code-Blocks are only available within the browser will be the operators of choice.

Code-Blocks are only available within the browser
inputResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
Code-Blocks are only available within the browserCode-Blocks are only available within the browser

If the false-branch is not required, it may simply be omitted (becomes Code-Blocks are only available within the browser), resulting in the terse syntax of:

Code-Blocks are only available within the browser

Comparison Operators

ComparisonOperatorTrue when
Equal ToCode-Blocks are only available within the browserCode-Blocks are only available within the browser is equal to Code-Blocks are only available within the browser
Not Equal ToCode-Blocks are only available within the browserCode-Blocks are only available within the browser is not equal to Code-Blocks are only available within the browser
Is String ContainedCode-Blocks are only available within the browserCode-Blocks are only available within the browser is contained in Code-Blocks are only available within the browser
Regex MatchesCode-Blocks are only available within the browserCode-Blocks are only available within the browser matches regex Code-Blocks are only available within the browser
Greater ThanCode-Blocks are only available within the browserCode-Blocks are only available within the browser is greater than Code-Blocks are only available within the browser
Greater Than Or EqualCode-Blocks are only available within the browserCode-Blocks are only available within the browser is greater than or equal to Code-Blocks are only available within the browser
Less ThanCode-Blocks are only available within the browserCode-Blocks are only available within the browser is less than Code-Blocks are only available within the browser
Less Than Or EqualCode-Blocks are only available within the browserCode-Blocks are only available within the browser is less than or equal to Code-Blocks are only available within the browser

Fallback Values

If a variable or an expression in general may return a Code-Blocks are only available within the browser-value, a fallback can be provided by appending it with a double-questionmark (Code-Blocks are only available within the browser), followed by the actual value.

Code-Blocks are only available within the browser
inputResult
Code-Blocks are only available within the browserCode-Blocks are only available within the browser
non-Code-Blocks are only available within the browserCode-Blocks are only available within the browser

Operator Precedence

The following table provides an overview of all existing operators as well as their precedence, where precedence is defined as follows: a higher number is evaluated first. Since multiplication has higher precedence than addition, the input Code-Blocks are only available within the browser is equal to Code-Blocks are only available within the browser; to specify an alternate order, make use of parentheses where needed, e.g. Code-Blocks are only available within the browser. or Code-Blocks are only available within the browser.

Associativity regards the order of operations on chains of operators of same precedence, with left-to-right posing the standard in the majority of cases, e.g. Code-Blocks are only available within the browser being equal to Code-Blocks are only available within the browser, whereas exponentiation (due to power-towers) is right-to-left, e.g. Code-Blocks are only available within the browser being equal to Code-Blocks are only available within the browser - the same holds true for all prefix-operators, e.g. negation, flip-sign and string-transform.

OperatorSymbolPrecedenceAssociativity
BranchingCode-Blocks are only available within the browser1left-to-right
DisjunctionCode-Blocks are only available within the browser2
ConjunctionCode-Blocks are only available within the browser3
Equal ToCode-Blocks are only available within the browser4
Not Equal ToCode-Blocks are only available within the browser
String ContainedCode-Blocks are only available within the browser
Matches RegexCode-Blocks are only available within the browser
Greater ThanCode-Blocks are only available within the browser5
Greater Than Or EqualCode-Blocks are only available within the browser
Less ThanCode-Blocks are only available within the browser
Less Than Or EqualCode-Blocks are only available within the browser
ConcatenationCode-Blocks are only available within the browser6
RangeCode-Blocks are only available within the browser7
AdditionCode-Blocks are only available within the browser8
SubtractionCode-Blocks are only available within the browser
MultiplicationCode-Blocks are only available within the browser9
DivisionCode-Blocks are only available within the browser
ModuloCode-Blocks are only available within the browser
ExponentiationCode-Blocks are only available within the browser10right-to-left
String-Split LiteralCode-Blocks are only available within the browser11left-to-right
String-Split RegexCode-Blocks are only available within the browser
RepeatCode-Blocks are only available within the browser
FallbackCode-Blocks are only available within the browser12
NegationCode-Blocks are only available within the browser13right-to-left
Flip SignCode-Blocks are only available within the browser
UppercaseCode-Blocks are only available within the browser
LowercaseCode-Blocks are only available within the browser
TitlecaseCode-Blocks are only available within the browser
Toggle CasingCode-Blocks are only available within the browser
SlugifyCode-Blocks are only available within the browser
AsciifyCode-Blocks are only available within the browser
TrimCode-Blocks are only available within the browser
ReverseCode-Blocks are only available within the browser
To LongCode-Blocks are only available within the browser
To DoubleCode-Blocks are only available within the browser
RoundCode-Blocks are only available within the browser
FloorCode-Blocks are only available within the browser
CeilCode-Blocks are only available within the browser
SubscriptingCode-Blocks are only available within the browser14left-to-right
SubstringCode-Blocks are only available within the browser
MemberCode-Blocks are only available within the browser
ParenthesesCode-Blocks are only available within the browser15