Does sightly template/call pattern contain default values?
given a template:
template.html
<template data-sly-template.tmpl=${ @ foo='bar', baz='buzz' }>
<p>the value of foo is ${foo}>
</template>
assuming it is called with:
<sly data-sly-use.myTemplate="template.html"
data-sly-call="${myTemplate.tmpl}"/>
I'd want an output of:
<p>the value of foo is bar</p>
Is this possible? I'd like to utilize this in helpers where say I have a flag that is usually "true" by default, but I'd like to be able to set to false in certain cases.
thank you
According to the HTL (Sightly) specification you can't set default parameters in that way. The values in the template block expressions are usage hints.
When some parameters are missing in a template call, that parameter would be initialised to an empty string within the template.
However, you can use the logical OR operator to set defaults within your HTL block expressions. Using your example:
<template data-sly-template.tmpl=${ @ foo='foo hint', baz='buzz hint' }>
<p>the value of foo is ${foo || 'bar'}</p>
</template>