Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Passing a model class to another file in sightly

Avatar

Level 2

Hi All,

 

Is it possible to initialize a Model class once in an html file using sightly and pass it to all the html files that are included using data-sly-inlcude.

For instance: With respect to the below screenshot, I'm initializing the MetaTagModel in the mainPage.html file using the object metaModel. I need the MetaTagModel in seo.html and common-seo.html as well. Is it possible to pass on the same metaModel object initialized in mainPage.html to the seo.html and common-seo.html instead of initializing the MetaTagModel again in those html files.

H_Malhotra_0-1647288047198.png

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @H_Malhotra, data-sly-inlcude will not allow you to pass parameter. Instead you can use combination of data-sly-call and data-sly-template - this is what you need to achieve your goal. Here are some links to the documentation and specification which also contains example code:

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @H_Malhotra, data-sly-inlcude will not allow you to pass parameter. Instead you can use combination of data-sly-call and data-sly-template - this is what you need to achieve your goal. Here are some links to the documentation and specification which also contains example code: