Expand my Community achievements bar.

SOLVED

a tag disappearing in rendered HTML (using HTL in href property)

Avatar

Level 9

so I have this piece of HTL

<div class="col-lg-6"><a href="${properties.targetURL@context='uri'}" class="black_transparent_button">View all fishes|${properties.targetURL}</a></div>

When I view the page (view as published) in my local AEM, this is the rendered HTML

<div class="col-lg-6">View all fishes|/content/myhost/en/fishes.html</div>

as can be seen, the a tag has disappeared.

I tried with/without context=uri and I get the same issue.

Any ideas what I could be doing wrong?

Thanks

edit

I also tried the code below and the a tag got stripped out as well. I have no issues when I use the full URL.

div class="col-lg-6"><a href="/content/myhost/en/fishes.html" class="black_transparent_button">View all fishes</a></div>

1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi,

We had tried to replicate your issue with the following code snippet that you had shared with valid targetURL and invalid targetURL -

<div class="col-lg-6">

<a href="${properties.targetURL@context='uri'}" class="black_transparent_button">View all fishes|${properties.targetURL}</a>

</div>

When we used valid targetURL (/content/projectname/na/us/en.html --> This page exists in our project), output was:

<div class="col-lg-6">

<a href="https://forums.adobe.com/content/projectname/na/us/en.html" class="black_transparent_button">View all fishes|/content/projectname/na/us/en.html</a>

</div>

When we used invalid targetURL (/content/experian/na/us/enabcgefgh.html --> This page exists in our project), output was:

<div class="col-lg-6">

View all fishes|/content/experian/na/us/enabcgefgh.html

</div>

NOTE:

When we use @ context ='uri', it validates URI for writing as an href or src attribute value, outputs nothing if validation fails.

Hence anchor tag is disappearing in your rendering HTML.

Even though @ context ='uri' is not used in our code, it's taken by default by sightly and hence it's causing you the issue.

Please refer the following URL for more information:

HTL Expression Language

We hope this information helps!

Regards,

TechAspect Solutions

View solution in original post

3 Replies

Avatar

Level 2

Did you have a space between the property, the @ and the context='uri' ? Because in the snippet you provided, I don't see one. Not sure if it's necessary to have one, but I always did it like that.

Avatar

Correct answer by
Level 7

Hi,

We had tried to replicate your issue with the following code snippet that you had shared with valid targetURL and invalid targetURL -

<div class="col-lg-6">

<a href="${properties.targetURL@context='uri'}" class="black_transparent_button">View all fishes|${properties.targetURL}</a>

</div>

When we used valid targetURL (/content/projectname/na/us/en.html --> This page exists in our project), output was:

<div class="col-lg-6">

<a href="https://forums.adobe.com/content/projectname/na/us/en.html" class="black_transparent_button">View all fishes|/content/projectname/na/us/en.html</a>

</div>

When we used invalid targetURL (/content/experian/na/us/enabcgefgh.html --> This page exists in our project), output was:

<div class="col-lg-6">

View all fishes|/content/experian/na/us/enabcgefgh.html

</div>

NOTE:

When we use @ context ='uri', it validates URI for writing as an href or src attribute value, outputs nothing if validation fails.

Hence anchor tag is disappearing in your rendering HTML.

Even though @ context ='uri' is not used in our code, it's taken by default by sightly and hence it's causing you the issue.

Please refer the following URL for more information:

HTL Expression Language

We hope this information helps!

Regards,

TechAspect Solutions