Skip to content

Instantly share code, notes, and snippets.

@gabrielwalt
Last active April 29, 2016 13:01
Show Gist options
  • Save gabrielwalt/0da85e4855070dc6264652269729eddf to your computer and use it in GitHub Desktop.
Save gabrielwalt/0da85e4855070dc6264652269729eddf to your computer and use it in GitHub Desktop.
Using synthetic resources with Sightly
/content
/example
@jcr:primaryType = "nt:unstructured"
@jcr:title = "Outer Component"
@sling:resourceType = "example/components/outer"
/apps
/example
/components
/inner
@jcr:primaryType = "cq:Component"
/inner.html
/inner.js
/outer
@jcr:primaryType = "cq:Component"
/outer.html
/outer.js
<div class="outer">
<h1>Outer Component</h1>
<ul>
<li>
<div class="inner">
<h2>Inner Component One</h2>
<p>Hello World!</p>
</div>
</li>
<li>
<div class="inner">
<h2>Inner Component Two</h2>
</div>
</li>
</ul>
</div>
<div class="inner">
<h2>${properties.jcr:title}</h2>
<p>${properties.text}</p>
</div>
<div class="outer" data-sly-use.logic="outer.js">
<h1>${properties.jcr:title}</h1>
<ul data-sly-list="${logic.children}">
<li data-sly-resource="${item}"></li>
</ul>
</div>
use(function () {
return {
children: [
{
resourceName: "one",
"sling:resourceType": "example2/components/inner",
"jcr:title": "Inner Component One",
"text": "Hello World!"
},
{
resourceName: "two",
"sling:resourceType": "example2/components/inner",
"jcr:title": "Inner Component Two"
}
]
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment