I was looking over the expression options used in sightly. I tried the below line of code, but it seems just render the text over the page, can someone provide use of options wi
Options in Sightly expressions can have two different kind of usage:
Note: to easily try out the examples provided below, you can install the REPL tool on your AEM instance.
On a plain expression (that is not located in a data-sly-*
statement), following options are possible:
${'Page {0} of {1}' @ format = [1, 10]}
Page 1 of 10
locale
allows to change the language if something different to the current page language is to be taken, and hint
allows to provide help to the translator and to distinguish strings that might be identical but that have different meanings.${'Number' @ i18n, locale = 'de', hint = 'Media DPS Folio Number'}
Nummer
${['foo', 'bar'] @ join = '-'}
foo-bar
${'<p>Hi!</p><script>alert("hack!")</script>' @ context = 'html'}
<p>Hi!</p>
Following statements allow the expression options as listed above, because these statements are similar to writing the expression without statement:
<p data-sly-text="${currentPage.title}">Lorem ipsum</p>
<p>${currentPage.title}</p>
<p data-sly-text="${'Page {0} of {1}' @ format = [1, 10]}"></p>
<p>Page 1 of 10</p>
<p href="#" data-sly-attribute.href="${currentPage.path}"></p>
<p href="${currentPage.path}"></p>
<p data-sly-attribute.title="${['foo', 'bar'] @ join = '-'}"></p>
<p title="foo-bar"></p>
<div data-sly-attribute="${properties}"></div>
Following statements accept any expression options as they allow to pass named parameters:
<p data-sly-use.bar="${'logic.js' @ foo = 'hello'}">${bar}</p>
use(function () { return this.foo + " world"; });
<p>hello world</p>
<template data-sly-template.tmpl="${@ foo}">${foo} world</template>
<p data-sly-call="${tmpl @ foo = 'hello'}"></p>
<p>hello world</p>
Following statements allow a custom list of options:
<div data-sly-include="${ @ path = 'path/to/template.html'}"></div>
<div data-sly-include="${'path/to/template.html'}"></div>
<div data-sly-include="path/to/template.html"></div>
path
) are:
<div data-sly-resource="par"></div>
data-sly-include
, but it additionally accepts following options:
And following statements allow no expression options: