mercredi 6 juillet 2016

How to assign a variable with Sightly/HTL

Hello World,

I'm actually working as a Java JEE developper on Adobe Experience Manager, sometimes we build mockups to test our code using Sightly template language. As the documentation is not very clear about how to assign a variable I'll provide you a tip. To assign a variable with Sightly you have to use data-sly-test and not data-sly-use as below:


<sly data-sly-test.yourvariable="${yourvalue}"></sly>

Then you can call your variable value as below:


<textarea rows="4" cols="50" name="name">{"Myvariable":${yourvariable}</textarea>

You can also use your variable in a test:


<sly data-sly-test="${yourvalue==true}">displaysomething</sly>

I hope this can help a bit.

Aucun commentaire:

Enregistrer un commentaire