Expand my Community achievements bar.

SOLVED

AEM 6.1 - Slightly

Avatar

Level 2

Hi guys,
How to handle
<meta name="description" content="${seoProps.description}" />
output:
<meta name="description" content="" />
Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Thanks all ! Sorry I didn't answer.

seoProps.description return String type.
if seoProps.description is empty, output is: content=""

I do it like this.

<meta name="description" content="${seoProps.description || true}">

output: <meta name="description" content />

Thanks,

View solution in original post

7 Replies

Avatar

Level 4

Hi.

Do you mean how to hide the tag if seoProps.description is null/empty?

Have you tried

<meta data-sly-test="${seoProps.description}" name="description" content="${seoProps.description}" />

?

HTL Test Statement

Regards,

Daniel.

Avatar

Administrator

I think Daniel has provided you with correct answer. Please verify it.  

~kautuk



Kautuk Sahni

Avatar

Level 1

Daniel is right, and also dont forget to escape if the content has special characters.

<meta data-sly-test="${seoProps.description}" name="description" content="${seoProps.description @ context = 'scriptString'} " />

Avatar

Level 4

@Conexio Group, Sightly is smart enough to figure out which context to use, most of the time:

HTL Display Context

So, for regular attributes, I wouldn't add anything.

Regards,

Daniel.

Avatar

Employee

Only for style and script it is mandatory to specify the context.

Avatar

Administrator

Hi 

Please confirm if the experts suggestion help you here.

~kautuk



Kautuk Sahni

Avatar

Correct answer by
Level 2

Thanks all ! Sorry I didn't answer.

seoProps.description return String type.
if seoProps.description is empty, output is: content=""

I do it like this.

<meta name="description" content="${seoProps.description || true}">

output: <meta name="description" content />

Thanks,