HTL Literals

HTL Literals

Literals holds a constant(fixed) value. It can be of 4 types mainly.

Boolean: Represents on off condition. It can be accessed as
${true} ${false}

Numbers: HTL Supports only positive digits , not negative numbers or floating.
${11}

Strings: Holds text values
${'mytext1'} ${"mytext2"}

For eg:
<p>${'John\'s car is "awesome !", Maria said'}</p>

Below special characters are allowed in HTL Strings.
\\ Backslash character
\' Single quote
\" Double quote
\t Tabulation
\n New line
\r Carriage return
\f Form feed
\b Backspace
\uXXXX (Unicode character specified by the four hexadecimal digits)

Arrays
An array is a collection of values that can be represented with a common name. An array will have an index ans ordered.

Samples:
//Array of 2 elements
${utilityArray[2]}
// Array of 5 digits
${[1,2,3,4,5]}
//print an array by names separated by ':'
${utilityArray.names @ join=':'}

//Dynamically accessing Array
<ul data-sly-list="${utilityArray.names}">
    <li>${ properties[item]}</li>
</ul>

No comments:

Post a Comment