sightly template to populate model class data | Community
Skip to main content
Level 4
August 18, 2017
Solved

sightly template to populate model class data

  • August 18, 2017
  • 18 replies
  • 7737 views

Hi All,

I have a requirement, where i will take input from author in <body> via component and display it in <head> section of the page. e.g. any script tag.

I am trying to use <data-sly-template>. Though, i am getting all values when i am using simple text. But when i am trying to access model class variables, i am getting null or no data.

    This is working fine: (written in component html and accessed in another html via data-sly-call)

       <template data-sly-template.tags>

                 some random text

       </template>

I want this, and its not working: (same as above)

<template data-sly-template.tags>

     ${tagModel.tagContent}

</template>

Info:I am creating the template in component html and want to use it in basePage.html.

         if i try to print  ${tagModel.tagContent} in the component html, i am getting value of tagContent.

Please help.

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

try page properties, without jcr:content

${pageProperties['iparsys/custom_tag/tagcontent']}

18 replies

Feike_Visser1
Adobe Employee
Adobe Employee
August 21, 2017

Sure you can do something like ${pageProperties['a/b/c']}

Level 4
August 21, 2017

So you mean:

${properties[jcr:content/iparsys/custom_tag].tagcontent}" ??

Feike_Visser1
Adobe Employee
Adobe Employee
August 21, 2017

${properties['jcr:content/iparsys/custom_tag/tagcontent']}

Level 4
August 21, 2017

here "tagcontent" is a property for custom_tag component.

I tried all the approaches, but getting null.

${properties['jcr:content/iparsys/custom_tag'].tagcontent}

${properties['jcr:content/iparsys/custom_tag\tagcontent']}

Still no luck.

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
August 21, 2017

try page properties, without jcr:content

${pageProperties['iparsys/custom_tag/tagcontent']}

Level 4
August 21, 2017

It worked.

Thanks a lot for your valuable support, time and patience.

Level 4
August 21, 2017

Something more complex with this:

Though earlier answer was right. Just an extension of the same.

What if we have many or more than 1 custom_tag components available in iparsys?

Feike_Visser1
Adobe Employee
Adobe Employee
August 21, 2017

It is the same, the path is unique.