sightly and javascript | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JustinEd3

Correction - I take it back. Sightly can be used to generate JS. It's just a bit ugly because you still need to use HTML tags and you must be sure to use data-sly-unwrap. Sorry for the misinformation. The script name would look like controller.js.html (vs. controller.js.jsp).

5 replies

balakumaran_k
Level 2
October 16, 2015

I am just trying to create a angular mobile app using sightly.

In a geomatrix outdoors app example, controller java script is generated via controller.js.jsp using sling. (E.g. geometrixx-outdoors-app/components/angular/ng-image). The java script is dynamically prepared using jcr properties.

How to do this in sightly?

PS: I have gone through the sightly documentation site but couldn't get how to implement this.

Adobe Employee
October 16, 2015

No. Sightly (at least now) is only able to generate HTML. You could generate JS inside <script> tags in an HTML page, but you can't use Sightly to generate a standalone JS script. The same would be true for JSON, CSS, etc.

JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Correction - I take it back. Sightly can be used to generate JS. It's just a bit ugly because you still need to use HTML tags and you must be sure to use data-sly-unwrap. Sorry for the misinformation. The script name would look like controller.js.html (vs. controller.js.jsp).

Level 8
October 16, 2015

What would best practice be however? I assume best practice would be use a JSP or Ecma to generate a dynamic JS file. Sightly is defined as being an HTML templating system right, so if you aren't generating HTML shouldn't you be using a different templating language? 

Adobe Employee
October 16, 2015

@orotas - that's what I meant by "ugly" smiley

Generating JS (or CSS or JSON) with Sightly is possible, but because it uses HTML constructs, it looks weird. Although arguably the same thing could be said about JSP or ESP.