How to set convenience variables in sightly? | Community
Skip to main content
October 16, 2015
Solved

How to set convenience variables in sightly?

  • October 16, 2015
  • 13 replies
  • 22413 views

Hey all,

is there a way to set variables in sightly? Basically I have a lot of variables in my html template and it's getting kind of messy, especially with things like inherited properties [1] and combination of properties for conditions [2]. In a jsp I could just use <c:set> but not here. Any suggestions?

Thanks!

Paul

[1] example for long properties: ${inheritedPageProperties['parBloc1/topbanner/narrow']}

[2] data-sly-test="${inheritedPageProperties['parBloc1/topbanner/narrow'] && inheritedPageProperties['parBloc1/topbanner/test']}"

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

hi,

What you can do is things like this:

<div data-sly-test.narrow="${inheritedPageProperties['parBloc1/topbanner/narrow']}">${narrow}</div>

And then later on...

<div data-sly-test=${ narrow && wcmmode.edit}">...</div>

Let me know if this works for you...

best,

Feike

13 replies

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

hi,

What you can do is things like this:

<div data-sly-test.narrow="${inheritedPageProperties['parBloc1/topbanner/narrow']}">${narrow}</div>

And then later on...

<div data-sly-test=${ narrow && wcmmode.edit}">...</div>

Let me know if this works for you...

best,

Feike

Feike_Visser1
Adobe Employee
Adobe Employee
November 7, 2018

Since HTL1.4 you can now also use data-sly-set.

Example here: htl-examples/htl1_4.html at master · heervisscher/htl-examples · GitHub

Dinu_Arya
Level 6
February 20, 2019

Will it work in AEM 6.2 or only in 6.4?