I have a problem similar to this one: Sightly in <script> tag not evaluating?
In that thread, the problem was that Sightly expressions inside a script element were not being rendered, and the solution was to add @ context = 'scriptString' to the expression.
My situation is a slightly different: Inside my HTML script element, I want to put a Sightly element:
<script id="availabilitiesTemplate" type="text/template" >
<sly data-sly-include="availabilitiesTemplate.html"></sly>
</script>
But the included file is not rendered to the output.
I suspect this is also a context problem, but I can't find any docs on setting the context on a <sly> element, and none of my experiments have worked. I've tried setting the context:
<script id="availabilitiesTemplate" type="text/template" >
<sly data-sly-include="${ availabilitiesTemplate.html @ context = 'scriptString' }"></sly>
</script>
I've also tried assigning the template with a data-sly-use expression:
<sly data-sly-use.avail="availabilitiesTemplate.html"></sly>
<script id="availabilitiesTemplate" type="text/template" >
${avail @ context='scriptString'}
</script>
Neither of these approaches works either; in all cases the output is
<script id="availabilitiesTemplate" type="text/template" >
</script>
Is there any way to get a <sly> element to render inside a <script> element?
Solved! Go to Solution.
Hi volcohen,
The problem is you are using the whole sightly syntax .
You can try with handlebar use this line to include resource in script.
<script id="my-handlebar-template" type="text/x-handlebars-template" data-sly-include="handlebar.html"></script> |
you can get more idea by go through this link How to use Sightly expressions in Handlebar templates, avoiding to explicitly set the context on eac...
Hi volcohen,
The problem is you are using the whole sightly syntax .
You can try with handlebar use this line to include resource in script.
<script id="my-handlebar-template" type="text/x-handlebars-template" data-sly-include="handlebar.html"></script> |
you can get more idea by go through this link How to use Sightly expressions in Handlebar templates, avoiding to explicitly set the context on eac...
That worked perfectly -- thanks!
Views
Replies
Total Likes
Views
Likes
Replies