sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r986085 - in /websites/staging/sling/trunk/content: ./ documentation/bundles/scripting/scripting-sightly.html
Date Tue, 19 Apr 2016 14:25:41 GMT
Author: buildbot
Date: Tue Apr 19 14:25:41 2016
New Revision: 986085

Log:
Staging update by buildbot for sling

Modified:
    websites/staging/sling/trunk/content/   (props changed)
    websites/staging/sling/trunk/content/documentation/bundles/scripting/scripting-sightly.html

Propchange: websites/staging/sling/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Apr 19 14:25:41 2016
@@ -1 +1 @@
-1739885
+1739935

Modified: websites/staging/sling/trunk/content/documentation/bundles/scripting/scripting-sightly.html
==============================================================================
--- websites/staging/sling/trunk/content/documentation/bundles/scripting/scripting-sightly.html
(original)
+++ websites/staging/sling/trunk/content/documentation/bundles/scripting/scripting-sightly.html
Tue Apr 19 14:25:41 2016
@@ -120,6 +120,7 @@ h2:hover > .headerlink, h3:hover > .head
 <li><a href="#modules">Modules</a></li>
 <li><a href="#the-use-api">The Use-API</a><ul>
 <li><a href="#sling-specific-use-api-extensions">Sling-specific Use-API Extensions</a><ul>
+<li><a href="#global-objects">Global Objects</a></li>
 <li><a href="#sling-models-use-provider">Sling Models Use Provider</a><ul>
 <li><a href="#passing-parameters">Passing parameters</a></li>
 </ul>
@@ -130,6 +131,7 @@ h2:hover > .headerlink, h3:hover > .head
 </ul>
 </li>
 <li><a href="#javascript-use-provider">JavaScript Use Provider</a><ul>
+<li><a href="#global-objects_1">Global Objects</a></li>
 <li><a href="#passing-parameters_2">Passing parameters</a></li>
 <li><a href="#caveats">Caveats</a></li>
 </ul>
@@ -148,7 +150,7 @@ h2:hover > .headerlink, h3:hover > .head
 <li><a href="https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly/engine"><code>org.apache.sling.scripting.sightly</code></a>
- the core Sightly Scripting Engine bundle</li>
 <li><a href="https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly/js-use-provider"><code>org.apache.sling.scripting.sightly.js.provider</code></a>
- the Sightly JavaScript Use Provider, implementing support for the <code>use</code>
JavaScript function</li>
 <li><a href="https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly/models-use-provider"><code>org.apache.sling.scripting.sightly.models.provider</code></a>
- <a href="https://sling.apache.org/documentation/bundles/models.html">Sling Models</a>
Use Provider</li>
-<li><a href="https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly/repl"><code>org.apache.sling.scripting.sightly.repl</code></a>
- Sightly Read-Eval-Print Loop Environment (REPL)</li>
+<li><a href="https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly/repl"><code>org.apache.sling.scripting.sightly.repl</code></a>
- Sightly Read-Eval-Print Loop Environment (REPL), useful for quickly prototyping scripts</li>
 </ol>
 <h1 id="the-use-api">The Use-API<a class="headerlink" href="#the-use-api" title="Permanent
link">&para;</a></h1>
 <p>The <a href="https://github.com/Adobe-Marketing-Cloud/sightly-spec/blob/1.2/SPECIFICATION.md#4-use-api">Sightly
HTML Templating Language Specification</a> explicitly defines two ways of implementing
support for business logic objects:</p>
@@ -242,6 +244,22 @@ h2:hover > .headerlink, h3:hover > .head
 </tbody>
 </table>
 <p>The <code>service.ranking</code> value of each Use Provider is configurable,
allowing for fine tuning of the order in which the providers are queried when <code>data-sly-use</code>
is called. However, in order to not affect core functionality the <code>RenderUnitProvider</code>
should always have the highest ranking. If you need to configure the providers' service ranking
head over to the configuration console at <a href="http://localhost:8080/system/console/configMgr">http://localhost:8080/system/console/configMgr</a>.</p>
+<h3 id="global-objects">Global Objects<a class="headerlink" href="#global-objects"
title="Permanent link">&para;</a></h3>
+<p>The following global objects are available to all Use objects, either as a request
attribute or as a property made available in the <code>javax.script.Bindings</code>
map or attached to the <code>this</code> context of the <code>use</code>
function:</p>
+<div class="codehilite"><pre>    <span class="n">currentNode</span>
        <span class="o">//</span> <span class="n">javax</span><span
class="p">.</span><span class="n">jcr</span><span class="p">.</span><span
class="n">Node</span>
+    <span class="n">currentSession</span>      <span class="o">//</span>
<span class="n">javax</span><span class="p">.</span><span class="n">jcr</span><span
class="p">.</span><span class="n">Session</span>
+    <span class="nb">log</span>                 <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">slf4j</span><span
class="p">.</span><span class="n">Logger</span>
+    <span class="n">out</span>                 <span class="o">//</span>
<span class="n">java</span><span class="p">.</span><span class="n">io</span><span
class="p">.</span><span class="n">PrintWriter</span>
+    <span class="k">properties</span>          <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">resource</span><span
class="p">.</span><span class="n">ValueMap</span>
+    <span class="n">reader</span>              <span class="o">//</span>
<span class="n">java</span><span class="p">.</span><span class="n">io</span><span
class="p">.</span><span class="n">BufferedReader</span>
+    <span class="n">request</span>             <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">SlingHttpServletRequest</span>
+    <span class="n">resolver</span>            <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">resource</span><span
class="p">.</span><span class="n">ResourceResolver</span>
+    <span class="n">resource</span>            <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">resource</span><span
class="p">.</span><span class="n">Resource</span>
+    <span class="n">response</span>            <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">SlingHttpServletResponse</span>
+    <span class="n">sling</span>               <span class="o">//</span>
<span class="n">org</span><span class="p">.</span><span class="n">apache</span><span
class="p">.</span><span class="n">sling</span><span class="p">.</span><span
class="n">api</span><span class="p">.</span><span class="n">scripting</span><span
class="p">.</span><span class="n">SlingScriptHelper</span>
+</pre></div>
+
+
 <h3 id="sling-models-use-provider">Sling Models Use Provider<a class="headerlink"
href="#sling-models-use-provider" title="Permanent link">&para;</a></h3>
 <p>Loading a Sling Model can be done with the following code:</p>
 <div class="codehilite"><pre>    <span class="nt">&lt;div</span>
<span class="err">data-sly-use.</span><span class="na">model3=</span><span
class="s">&quot;org.example.models.Model3&quot;</span><span class="nt">&gt;</span>
@@ -409,6 +427,20 @@ Assuming the following content structure
 
 
 <p>Similar to the Java Use Provider, loading the script using a relative path allows
inheriting components to overlay just the Use script, without having to also overlay the calling
Sightly script.</p>
+<h4 id="global-objects_1">Global Objects<a class="headerlink" href="#global-objects_1"
title="Permanent link">&para;</a></h4>
+<p>Besides the global objects available to all Use Providers, the JavaScript Use Provider
also provides the following global objects available in the context of the <code>use</code>
function:</p>
+<div class="codehilite"><pre><span class="n">console</span>     
   <span class="o">//</span> <span class="n">basic</span> <span
class="n">wrapper</span> <span class="n">on</span> <span class="n">top</span>
<span class="n">of</span> <span class="nb">log</span><span class="p">,</span>
<span class="n">but</span> <span class="n">without</span> <span
class="n">formatting</span> <span class="o">/</span> <span class="n">throwable</span>
<span class="n">support</span>
+<span class="n">exports</span>         <span class="o">//</span>
<span class="n">basic</span> <span class="n">Java</span> <span
class="n">implementation</span> <span class="n">of</span> <span class="n">CommonJS</span>
<span class="o">-</span> <span class="n">http</span><span class="p">:</span><span
class="o">//</span><span class="n">requirejs</span><span class="p">.</span><span
class="n">org</span><span class="o">/</span><span class="n">docs</span><span
class="o">/</span><span class="n">commonjs</span><span class="p">.</span><span
class="n">html</span>
+<span class="n">module</span>          <span class="o">//</span>
<span class="n">basic</span> <span class="n">Java</span> <span
class="n">implementation</span> <span class="n">of</span> <span class="n">CommonJS</span>
<span class="o">-</span> <span class="n">http</span><span class="p">:</span><span
class="o">//</span><span class="n">requirejs</span><span class="p">.</span><span
class="n">org</span><span class="o">/</span><span class="n">docs</span><span
class="o">/</span><span class="n">commonjs</span><span class="p">.</span><span
class="n">html</span>
+<span class="n">setImmediate</span>    <span class="o">//</span>
<span class="n">Java</span> <span class="n">implementation</span>
<span class="n">of</span> <span class="n">the</span> <span class="n">Node</span><span
class="p">.</span><span class="n">js</span> <span class="n">setImmediate</span>
<span class="k">function</span>
+<span class="n">setTimeout</span>      <span class="o">//</span>
<span class="n">Java</span> <span class="n">implementation</span>
<span class="n">of</span> <span class="n">the</span> <span class="n">Node</span><span
class="p">.</span><span class="n">js</span> <span class="n">setTimeout</span>
<span class="k">function</span>
+<span class="n">sightly</span>         <span class="o">//</span>
<span class="n">the</span> <span class="n">namespace</span> <span
class="n">object</span> <span class="n">under</span> <span class="n">which</span>
<span class="n">the</span> <span class="n">asynchronous</span> <span
class="n">Resource</span><span class="o">-</span><span class="n">API</span>
<span class="n">implemented</span> <span class="n">by</span>
+                <span class="o">//</span> <span class="n">org</span><span
class="p">.</span><span class="n">apache</span><span class="p">.</span><span
class="n">sling</span><span class="p">.</span><span class="n">scripting</span><span
class="p">.</span><span class="n">sightly</span><span class="p">.</span><span
class="n">js</span><span class="p">.</span><span class="n">provider</span>
<span class="n">is</span> <span class="n">made</span> <span class="n">available</span>
<span class="n">to</span> <span class="n">consumers</span>
+<span class="n">use</span>             <span class="o">//</span>
<span class="n">the</span> <span class="n">use</span> <span class="k">function</span>
+</pre></div>
+
+
+<p>With the exception of the <code>console</code> and <code>use</code>
objects, all the other global objects implemented by the JavaScript Use Provider are present
in order to support the asynchronous Resource-API implemented by <code>org.apache.sling.scripting.sightly.js.provider</code>.
However, this was deprecated starting with version 1.0.8 - see <a href="https://issues.apache.org/jira/browse/SLING-4964">SLING-4964</a>.</p>
 <h4 id="passing-parameters_2">Passing parameters<a class="headerlink" href="#passing-parameters_2"
title="Permanent link">&para;</a></h4>
 <p>Passed parameters will be made available to the Use object as properties of <code>this</code>.
Assuming the following markup:</p>
 <div class="codehilite"><pre>    <span class="nt">&lt;div</span>
<span class="err">data-sly-use.</span><span class="na">logic=</span><span
class="s">&quot;</span><span class="cp">${</span><span class="s">&#39;logic.js&#39;</span>
<span class="err">@</span> <span class="n">colour</span><span class="o">=</span><span
class="s">&#39;red&#39;</span><span class="p">,</span> <span
class="n">year</span><span class="o">=</span><span class="mi">2017</span><span
class="cp">}</span><span class="s">&quot;</span><span class="nt">&gt;</span>
@@ -606,7 +638,7 @@ Assuming the following content structure
     </tr>
 </table>
       <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
-        Rev. 1739885 by radu on Tue, 19 Apr 2016 09:55:07 +0000
+        Rev. 1739935 by radu on Tue, 19 Apr 2016 14:25:27 +0000
       </div>
       <div class="trademarkFooter"> 
         Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project



Mime
View raw message