i'm trying to display two different set of script pased on existence of propriety model in sightly AEM.
Is this use of && operator correct?:
<sly data-sly-test="${!metaFields.lastModified && metaFields.autore}" data-sly-unwrap>
something inside here...
</sly>
Thank you in advance
If you mean to render the contents of the sly
tag when metaFields.lastModified
is falsy and metaFields.autore
is truthy, then yes, this use of the &&
operator is correct. If you have doubts as to how to use logical operators in HTL expressions, it's quite clearly documented.
The contents of your tag will be displayed as long as they're allowed in the current display context. Keep in mind that this may not be the case if you're trying to render JavaScript this way.
Additionally, data-sly-unwrap
on sly
tags is superfluous unless you're using an early version of the language.