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 browserIn 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 browserWhen 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 browserNumbers
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 browserFractional values may be depicted using the decimal-dot (Code-Blocks are only available within the browser).
Code-Blocks are only available within the browserWhere the leading zero can be dropped entirely:
Code-Blocks are only available within the browserAdditionally, 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 browserConcatenation 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 browserwill result in
Code-Blocks are only available within the browserString-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 browserone 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 browserInterpolations 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 browserIn 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 browserMathematical 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.
Operation | Operator | Precedence |
---|---|---|
Addition | Code-Blocks are only available within the browser | 1 |
Subtraction | Code-Blocks are only available within the browser | 1 |
Multiplication | Code-Blocks are only available within the browser | 2 |
Division | Code-Blocks are only available within the browser | 2 |
Modulo | Code-Blocks are only available within the browser | 2 |
Exponentiation | Code-Blocks are only available within the browser | 3 |
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 browserwill 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 browserwill 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 browserwill 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 browserwill 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 browserwill 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 browserThe 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 browserThe 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 browserThe 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 browserThe 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.
Operation | Operator | Result |
---|---|---|
Uppercase | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Lowercase | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Titlecase | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Toggle Casing | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Slugify | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Asciify | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Trim | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Reverse | Code-Blocks are only available within the browser | Code-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 browserThis 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 browserItems may also once again be lists themselves, allowing for a tuple-style dataset.
Code-Blocks are only available within the browserAnd thereby give rise to more advanced concepts of templating.
Code-Blocks are only available within the browserImmediate 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 browserAnalogous 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 browserRange 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 browseris thereby equivalent to
Code-Blocks are only available within the browserThis 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 browserSubstring 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 Index | 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 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 |
---|---|---|---|---|---|---|---|---|---|---|
Positive Index | 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 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 |
Letter | 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 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 |
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:
Operation | Result |
---|---|
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 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 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 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 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 browserSpecifying delimiters will yield the according sub-sequences:
Operation | Result |
---|---|
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 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 browserwill yield
Code-Blocks are only available within the browserRepeat 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:
Operation | Result |
---|---|
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 browser |
This operator may especially come in handy when generating spacers.
Code-Blocks are only available within the browserLiterals
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 browserAccessing 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 browsermy_index | Result |
---|---|
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 browser |
Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Indices can also be specified immediately, with
Code-Blocks are only available within the browserresulting 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_index | Result |
---|---|
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 browser |
Code-Blocks are only available within the browser | Code-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 browsermy_key | Result |
---|---|
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 browser |
Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
Keys may also be specified immediately, with
Code-Blocks are only available within the browserresulting 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 browserthe 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 browserExpression | Result |
---|---|
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 browser |
Analogously to maps, keys may also be specified dynamically, with
Code-Blocks are only available within the browseror even immediately, using
Code-Blocks are only available within the browserresulting in Code-Blocks are only available within the browser.
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 browservalue | Result |
---|---|
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 |
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 browserlhs | rhs | Result |
---|---|---|
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 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 browser | Code-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 browserlhs | rhs | Result |
---|---|---|
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 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 browser | Code-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 browserinput | Result |
---|---|
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 |
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 browserComparison Operators
Comparison | Operator | True when |
---|---|---|
Equal To | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is equal to Code-Blocks are only available within the browser |
Not Equal To | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is not equal to Code-Blocks are only available within the browser |
Is String Contained | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is contained in Code-Blocks are only available within the browser |
Regex Matches | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser matches regex Code-Blocks are only available within the browser |
Greater Than | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is greater than Code-Blocks are only available within the browser |
Greater Than Or Equal | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is greater than or equal to Code-Blocks are only available within the browser |
Less Than | Code-Blocks are only available within the browser | Code-Blocks are only available within the browser is less than Code-Blocks are only available within the browser |
Less Than Or Equal | Code-Blocks are only available within the browser | Code-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 browserinput | Result |
---|---|
Code-Blocks are only available within the browser | Code-Blocks are only available within the browser |
non-Code-Blocks are only available within the browser | Code-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.
Operator | Symbol | Precedence | Associativity |
---|---|---|---|
Branching | Code-Blocks are only available within the browser | 1 | left-to-right |
Disjunction | Code-Blocks are only available within the browser | 2 | |
Conjunction | Code-Blocks are only available within the browser | 3 | |
Equal To | Code-Blocks are only available within the browser | 4 | |
Not Equal To | Code-Blocks are only available within the browser | ||
String Contained | Code-Blocks are only available within the browser | ||
Matches Regex | Code-Blocks are only available within the browser | ||
Greater Than | Code-Blocks are only available within the browser | 5 | |
Greater Than Or Equal | Code-Blocks are only available within the browser | ||
Less Than | Code-Blocks are only available within the browser | ||
Less Than Or Equal | Code-Blocks are only available within the browser | ||
Concatenation | Code-Blocks are only available within the browser | 6 | |
Range | Code-Blocks are only available within the browser | 7 | |
Addition | Code-Blocks are only available within the browser | 8 | |
Subtraction | Code-Blocks are only available within the browser | ||
Multiplication | Code-Blocks are only available within the browser | 9 | |
Division | Code-Blocks are only available within the browser | ||
Modulo | Code-Blocks are only available within the browser | ||
Exponentiation | Code-Blocks are only available within the browser | 10 | right-to-left |
String-Split Literal | Code-Blocks are only available within the browser | 11 | left-to-right |
String-Split Regex | Code-Blocks are only available within the browser | ||
Repeat | Code-Blocks are only available within the browser | ||
Fallback | Code-Blocks are only available within the browser | 12 | |
Negation | Code-Blocks are only available within the browser | 13 | right-to-left |
Flip Sign | Code-Blocks are only available within the browser | ||
Uppercase | Code-Blocks are only available within the browser | ||
Lowercase | Code-Blocks are only available within the browser | ||
Titlecase | Code-Blocks are only available within the browser | ||
Toggle Casing | Code-Blocks are only available within the browser | ||
Slugify | Code-Blocks are only available within the browser | ||
Asciify | Code-Blocks are only available within the browser | ||
Trim | Code-Blocks are only available within the browser | ||
Reverse | Code-Blocks are only available within the browser | ||
To Long | Code-Blocks are only available within the browser | ||
To Double | Code-Blocks are only available within the browser | ||
Round | Code-Blocks are only available within the browser | ||
Floor | Code-Blocks are only available within the browser | ||
Ceil | Code-Blocks are only available within the browser | ||
Subscripting | Code-Blocks are only available within the browser | 14 | left-to-right |
Substring | Code-Blocks are only available within the browser | ||
Member | Code-Blocks are only available within the browser | ||
Parentheses | Code-Blocks are only available within the browser | 15 |