AEM sightly - include html - Pass data
Hi all,
I'm trying to include html files in sightly and having issue while passing attributes to html file.
Below is what I'm trying:
original HTL code:
<sly data-sly-use.model="com.test.SampleModel">
Heading: ${model.title}
<!-- PART 1 -->
<sly data-sly-list.pageList1="${model.pagesList1}">
<ul>
<li>
Page Title: ${pageList1.title}
</li>
</ul>
</sly>
<!-- PART 2 -->
<sly data-sly-list.pageList2="${model.pagesList2}">
<ul>
<li>
Page Title: ${pageList2.title}
</li>
</ul>
</sly>
</sly>
I want to have different html for PART1 & PART2 and write logic over there.
Wanted to change something like below:
<sly data-sly-use.model="com.test.SampleModel">
Heading: ${model.title}
<sly data-sly-include="part1.html"></sly>
<!-- PART 2 -->
<sly data-sly-include="part2.html"></sly>
</sly>
But questions is how do I pass model object to the included file so that I don't need to call sling model on each file?
please advise.