How to keep attribute for empty string value in sightly

sushant84 06-09-2019

In sightly if i am getting empty string value then i am not getting that attribute in html page. I am using AEM 6.4

e.g  <sly data-sly-test.iconVal=" ">

<a data-icon="${iconVal}" />

here i am not getting data-icon attribute in html page because iconVal value is empty string.

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (1)

Answers (1)


Note that an attribute (either literal or set via data-sly-attribute) whose value evaluates to the empty string will be removed in the final markup. The one exception to this rule is that a literal attribute set to a literal empty string will be preserved. For example,

For example,

<div class="${''}""${''}"></div>




<div class=""""></div>


<div class=""></div>

So, try to set a literal value to the attribute if its null.