-1

We have a requirement wherein we need to create a template dynamically using the sling model response.

The challenge here is we have got some common components that we want to use for building up our template.

Is there a way that I can set the common components properties using slightly.

Any help is appreciated.

  • Your question doesn't explain the business objective. Adding the end requirement you want to achieve than asking how to create templates dynamically should get you better solutions. Creating templates dynamically isn't the right way if the kind of components that you want to display depends on code customizing the page component is the way to go. – Sharath Madappa Oct 18 '19 at 15:26

1 Answers1

0

You can initialise the Sling Model with the HTL Use API:

<sly data-sly-use.myModel="mypackage.MyModel">

and then access it's properties/methods in HTL Expressions:

${myModel.myProperty}

For a simple example, have a look at the title component for AEM: https://github.com/adobe/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/wcm/components/title/v2/title/title.html

Vlad
  • 10,602
  • 2
  • 36
  • 38