Created
September 12, 2017 23:15
-
-
Save bdelacretaz/694febf6779151f1d830f88a00e6916a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
/* Demonstrate Sling Query in server-side Javascript */ | |
var $ = Packages.org.apache.sling.query.SlingQuery.$ | |
var SearchStrategy = Packages.org.apache.sling.query.api.SearchStrategy | |
var resourceResolver = resource.getResourceResolver() | |
var result = { | |
siblings : $(resource).siblings(), | |
rootChildren : $(resource).parents().last().children(), | |
queryResult : $(resourceResolver) | |
.searchStrategy(SearchStrategy.QUERY) | |
.find("nt:base[title=foo]") | |
} | |
%> | |
Date = <%= new Date() %> | |
Resource = <%= resource %> | |
<% for(i in result) { %> | |
<%= i %> = <%= result[i] %> | |
<% } %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment