Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

What exactly interprets Sightly?

Avatar

Level 5

Wondering what exactly in the request chain interprets sightly. Like any conforming java app server would interpret JSP scriptlets, what exactly in the processing chain processes Sightly? Is there a plan to have the interpreter as a pluggable module that can be imported in other app servers like JSP?

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

What is Sightly?

Sightly is an HTML templating language, introduced with AEM 6.0. It takes the place of JSP (Java Server Pages) and ESP (ECMAScript Server Pages) as the preferred templating system for HTML. The name “Sightly” (meaning “pleasing to the eye”) highlights its focus on keeping your markup beautiful, and thus maintainable, once made dynamic.

As in all HTML server-side templating systems, a Sightly file defines the output sent to the browser by specifying the HTML itself, some basic presentation logic and variables to be evaluated at runtime.

But, Sightly differs from other templating systems in three main ways:

  • Security by Default: Sightly automatically filters and escapes all variables being output to the presentation layer to prevent cross-site-scripting (XSS) vulnerabilities. As Sightly understands the HTML syntax, it is capable to automatically detect the scope in which variables are placed, and automatically do proper context-aware escaping and XSS protection. Yet, it is possible to manually control the display context if needed.
  • Separation of Concerns: The expressiveness of the Sightly template language is purposely limited, in order to make sure that a real programming language is used to express the corresponding presentation logic. This optional logic is invoked from Sightly expressions with the Use-API pattern, making it easy to understand what is called for a given view, and to potentially have different logic for different views of the same resource.
  • Sightly is HTML5: A Sightly file is itself a valid HTML5 file. All Sightly-specific syntax is expressed either within adata attribute, or within HTML text. Any Sightly file opened as HTML in an editor will automatically benefit from any features provided by that editor for regular HTML.

Sightly aims to reduce the time to market and the total cost of ownership for AEM projects:

  • Reducing project costs
    by making components editable for front-end developers.
  • Reducing operational costs
    by securing the templates against XSS injections.
  • Reducing maintenance costs
    by keeping templates readable and valid HTML5.

Documentation Link:- https://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html

PDF Sightly Component Development :- http://dev.day.com/content/ddc/en/gems/introduction-to-sightly/_jcr_content/par/download/file.res/Si...

Link:- http://www.aemcq5tutorials.com/tutorials/sightly-new-features-vs-jsp-aem/

//Difference between Sightly vs JSP

Link:- http://labs.6dglobal.com/blog/2014-05-22/sightly-vs-handlebars-vs-jsp-comparing-scripting-languages/

//Sightly vs Handlebars vs JSP

PS: we can not use it beyond the scope of AEM as of now.

I hope this would help you.

Thanks and Regards

Kautuk Sahni

 



Kautuk Sahni

View solution in original post

6 Replies

Avatar

Correct answer by
Administrator

Hi 

What is Sightly?

Sightly is an HTML templating language, introduced with AEM 6.0. It takes the place of JSP (Java Server Pages) and ESP (ECMAScript Server Pages) as the preferred templating system for HTML. The name “Sightly” (meaning “pleasing to the eye”) highlights its focus on keeping your markup beautiful, and thus maintainable, once made dynamic.

As in all HTML server-side templating systems, a Sightly file defines the output sent to the browser by specifying the HTML itself, some basic presentation logic and variables to be evaluated at runtime.

But, Sightly differs from other templating systems in three main ways:

  • Security by Default: Sightly automatically filters and escapes all variables being output to the presentation layer to prevent cross-site-scripting (XSS) vulnerabilities. As Sightly understands the HTML syntax, it is capable to automatically detect the scope in which variables are placed, and automatically do proper context-aware escaping and XSS protection. Yet, it is possible to manually control the display context if needed.
  • Separation of Concerns: The expressiveness of the Sightly template language is purposely limited, in order to make sure that a real programming language is used to express the corresponding presentation logic. This optional logic is invoked from Sightly expressions with the Use-API pattern, making it easy to understand what is called for a given view, and to potentially have different logic for different views of the same resource.
  • Sightly is HTML5: A Sightly file is itself a valid HTML5 file. All Sightly-specific syntax is expressed either within adata attribute, or within HTML text. Any Sightly file opened as HTML in an editor will automatically benefit from any features provided by that editor for regular HTML.

Sightly aims to reduce the time to market and the total cost of ownership for AEM projects:

  • Reducing project costs
    by making components editable for front-end developers.
  • Reducing operational costs
    by securing the templates against XSS injections.
  • Reducing maintenance costs
    by keeping templates readable and valid HTML5.

Documentation Link:- https://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html

PDF Sightly Component Development :- http://dev.day.com/content/ddc/en/gems/introduction-to-sightly/_jcr_content/par/download/file.res/Si...

Link:- http://www.aemcq5tutorials.com/tutorials/sightly-new-features-vs-jsp-aem/

//Difference between Sightly vs JSP

Link:- http://labs.6dglobal.com/blog/2014-05-22/sightly-vs-handlebars-vs-jsp-comparing-scripting-languages/

//Sightly vs Handlebars vs JSP

PS: we can not use it beyond the scope of AEM as of now.

I hope this would help you.

Thanks and Regards

Kautuk Sahni

 



Kautuk Sahni

Avatar

Level 10

When you write code in sightly file in .html file, a Java file will be generate with the help of it. That will be done by sightly engine.

Those files can be found here /var/classes/dd8d5f1b-8f16-4378-a712-accecb264070/sightly/1.0.2/apps

When you write JS-USE api, it will be rendered by Rhino engine.

This should give you more insight of sightly:

http://blog.justinedelson.com/2016/01/18/adding-javascript-functions-for-sightly-to-use.html

Avatar

Level 9

Hi All,

Thanks a lot for your inputs here. It gave a good amount of information.

Avatar

Level 5

That's awesome information. Thanks all.

 

The only issue I have with Sightly is it is very specific to AEM and is not as intuitive as say handlebars js templating or jquery in general. Knowing slightly also doesn't help beyond AEM in contrast to JSP which is understood by any java platform.

Anyways, thanks a lot for the input. This is very helpful.

Avatar

Level 1

I am unable to see any file under /var/classes. any idea why this might be happening ?

Avatar

Level 5

FYI - since labs.6global.com is down, here's a link to the Sightly vs. Handlebars vs. JSP comparison on my personal blog:

https://www.danklco.com/posts/2014/05/22/sightly-vs-handlebars-vs-jsp-comparing-scripting-languages/