I am trying to write a basic Sightly user-grid component by referencing a JSP user-grid component. What I seem to be having trouble with is the expressive language seems to be written out without being evaluated in the <script> tag.
For instance in JSP:
<script type="text/javascript"> var baseURL = "<%= currentNode.getPath() %>"; $CQ(function () { $CQ('.user-table').flexigrid({ url: baseURL + '.json', // This will trigger a POST request back to CQ //more params }); }); </script>
And I should be able to rewrite this in Sightly as:
<script type="text/javascript"> var baseURL = "${currentNode.path}"; $CQ(function () { $CQ('.user-table').flexigrid({ url: baseURL + '.json', // This will trigger a POST request back to CQ //more params }); }); </script>
But for some reason the HTML is rendered as:
var baseURL = "";
I have only seen this behavior in the <script> tag, every other tag is would be rendered as the path to the currentNode. Any thoughts or suggestions are welcome!
Solved! Go to Solution.
You need to set the context in the string. You can find the documentation around that here: http://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html#Display%20Context
I believe for your needs you'll want to use:
var baseURL = "${currentNode.path @ context='scriptString'}";
Have you read through all five parts of this subject specified here:
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2014/01/sightly-preview-part1.html
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2014/01/sightly-preview-part2.html
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2014/01/sightly-preview-part3.html
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2014/01/sightly-preview-part4.html
http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2014/01/sightly-preview-part5.html
Views
Replies
Total Likes
You need to set the context in the string. You can find the documentation around that here: http://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html#Display%20Context
I believe for your needs you'll want to use:
var baseURL = "${currentNode.path @ context='scriptString'}";
Thanks! I haven't really used the @context param yet, so it's good to see it actually used.
Views
Replies
Total Likes