Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Passing a model class to another file in sightly

Avatar

Level 1

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: