Sightly Component Development
Sightly Component Development
Efficient
APIs to OSGi bundles Java Developer
Business
Logic
– Java/OSGi
– Business logic
JSP
<a href="<%= xssAPI.getValidHref(properties.get("link", "#")) %>" <%
String title = properties.get("jcr:title", "");
if (title.length() > 0) {
%>title="<%= xssAPI.encodeForHTMLAttr(title) %>"<%
} %>>
<%= xssAPI.encodeForHTML(properties.get("jcr:description", "")) %>
</a>
Expression Language
${properties.myProperty}
Block Statements
<p data-sly-test="${isVisible}">${text}</p>
Use-API
<p data-sly-use.obj="script.js">${obj.text}</p>
Variables
${myVar}
${properties.propName}
${properties.jcr:title}
${properties['my property']}
${properties[myVar]}
Conditional
${myChoice ? varOne : varTwo}
Grouping
${varOne && (varTwo || varThree)}
Internationalization
${'Page' @ i18n}
${'Page' @ i18n, hint='Translation Hint'}
${'Page' @ i18n, source='user'}
${'Page' @ i18n, locale='en-US'}
Array Join
${['one', 'two'] @ join='; '}
Output
<div>Hello World</div>
Server-side JavaScript
– Can easily be edited by web developers
Java
– Fast We are working on improving
– Easy to debug that for server-side JavaScript
– Can be located in the component folder, or in an OSGi bundle
Output
Hello World
Use unwrap with care, the template should correspond as much as
possible to the output.
Output
<span class="active" title="Hi!">Hello World</span>
Use element with care, it can make the template confusing when the
element name gets changed.
Output
<p>text</p>
<p>is true</p>
Output
<ol>
<li>Triangle Page</li>
<li>Square Page</li>
</ol>
Output
<article><!-- Result of the rendered resource --></article>
Includes the rendering of the indicated template (Sightly, JSP, ESP, etc.)
<section data-sly-include="path/to/template.html"></section>
Output
<section><!-- Result of the rendered resource --></section>
Output
<div><span class="example">Hi!</span></div>
Web Developer
Component
Business
Java Developer
Logic
Brackets plugin
!
– Sightly code completion & syntax highlighting
– Content nodes & properties manipulation
Eclipse plugin
!
– Content nodes & properties manipulation
– Bundle development & hot deployment
Java Docs
http://docs.adobe.com/content/docs/en/aem/6-0/develop/ref/javadoc/index.html?com/adobe/
cq/sightly/WCMUse.html