[ https://issues.apache.org/jira/browse/SLING-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12605638#action_12605638 ]
Bertrand Delacretaz commented on SLING-466: ------------------------------------------- The JST engine is much improved in revision 668714, with separate processing of the template's head and body elements. Given a node with these properties: sling:resourceType: foo description: Hello, Sling world title: Sling JST test And this JST template stored at /apps/foo/foo.jst: <html> <head> <title><%= currentNode.title %></title> <link rel="stylesheet" type="text/css" href="/apps/foo/foo.css"/> </head> <body style="color:blue"> <h1>currentNode test</h1> Changed 1 <div> This is html.jst, path=<%= currentNode.description %>. </div> <div> <h1>Sling client library test</h1> root resource type= <b><% out.write(Sling.getContent("/")["sling:resourceType"]); %></b>. </div> </body> </html> Requesting the node with an html extension outputs this: <html> <head> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Sling JST test</title> <link href="/apps/foo/foo.css" rel="stylesheet" type="text/css"> <script src="/system/sling.js"></script><script language="javascript">var currentNode={"description":"Hello, Sling world","sling:resourceType":"foo","testInfiniteLoop":"true","jcr:primaryType":"nt:unstructured","title":"Sling JST test"};</script> </head> <body style="color:blue"> <div id="JstDefaultRendering"><h1>Node dumped by HtmlRendererServlet</h1> <p>Node path: <b>/xx</b></p> <p>Resource metadata: <b>{sling.resolutionPath=/xx}</b></p> <h2>Node properties</h2> description: <b>Hello, Sling world</b><br/>sling:resourceType: <b>foo</b><br/>testInfiniteLoop: <b>true</b><br/>jcr:primaryType: <b>nt:unstructured</b><br/>title: <b>Sling JST test</b><br/></div> <script language="javascript"> var e = document.getElementById("JstDefaultRendering"); e.parentNode.removeChild(e); </script><script src="/apps/foo/foo.jst.jst.js"></script> </body> </html> And the /apps/foo/foo.jst.jst.js script that's referred to above is generated to be: out=document; out.write("<h1>currentNode test</h1>\n"); out.write("Changed 1\n"); out.write("<div>\n"); out.write("This is html.jst, path=");out.write( currentNode.description );out.write(".\n"); out.write("</div>\n"); out.write("\n"); out.write("<div>\n"); out.write("<h1>Sling client library test</h1>\n"); out.write("root resource type=\n"); out.write("<b>"); out.write(Sling.getContent("/")["sling:resourceType"]); out.write("</b>.\n"); out.write("</div> \n"); > JST scripting engine: render indexable HTML and separate javascript code > ------------------------------------------------------------------------ > > Key: SLING-466 > URL: https://issues.apache.org/jira/browse/SLING-466 > Project: Sling > Issue Type: Improvement > Components: Scripting > Reporter: Bertrand Delacretaz > Priority: Minor > > The JST scripting engine should output a default HTML rendering, meant to be > indexed by search engines, with a <script> element that points to a separate > javascript resource to render the page. > The idea is that the javascript code will be cached by client browsers, being > the same for all resources that have the same sling:resourceType. > The HTML rendering should include a meaningful <title> element, using the > value of a property named "title" or "description", if present, or the node > name if not. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.