2

Examine this

<a href="${mybean.href}" data-sly-test="${mybean.href}">
  <img src="myimage.jpg" />
</a>

What we need

when data-sly-test="${mybean.href}" evaluates to false, only hide the anchor tag, and not its child elements. The default behavior is that the img tag will disappear also when the anchor tag disappears. We only want to hide the wrapper tag.

I expect some paramater like this

<a href="${mybean.href}" data-sly-test="${mybean.href @ hideChildren=false}">
  <img src="myimage.jpg" />
</a>

1 Answer 1

5

You can use the data-sly-unwrap in your anchor tag as shown below example where mybean.href true result removing of the anchor tag and producing only <img src="myimage.jpg" />

Example

<a href="http://www.google.com" data-sly-test="${mybean.href}" data-sly-unwrap>
  <img src="myimage.jpg" />
</a>

For your case the following solution should work

<a href="${mybean.href}" data-sly-unwrap="${!mybean.href}">
  <img src="myimage.jpg" />
</a>
1
  • As usual, obvious in retrospect. Thank you, this is working great! Jan 26, 2017 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.