You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Renaud Richardet <re...@apache.org> on 2008/09/02 11:14:46 UTC

Re: ESP syntax

hi,

I was also looking for some documentation re ESP, thanks for the
pointers. I have put a demo ESP file in the wiki:
http://cwiki.apache.org/confluence/display/SLING/Scripting+variables

HTH, Renaud


jc...@proxymit.net schrieb:

Hi,

I've been looking for the Sling ESP reference documentation, but
google was not really helpful in this. Can somebody point to some doc?

To complement Bertrand's post:

ESP is much like JSP but using JavaScript (Rhino implementation)
instead of Java as the scripting language.

As such by default an ESP is in script mode, that is everything is
written to the response as is. The following constructs are available:

<%= expr %>: Evaluates the expression expr and prints the result <%
javascript %>: Runs the javascript code <%-- comment -->: ESP comment
removed while preprocessing the script

Just like with JSP, ESP scripts are converted into plain JavaScript
code on the run, that is a construct like

<% for (var i in list) { %> <p><%= i %>: <%= list[i] %></p> <% } %>

is converted to

for (var i in list) { out.print("\n"); out.print("<p>"); out.print(i);
out.print(": "); out.print("list[i]"); out.print("</p>\n"); }

(Note I split the line in the loop for readability).

Hope this helps.

Regards Felix

Thanks, Juerg

Re: ESP syntax

Posted by Alexander Klimetschek <ak...@day.com>.
Cool, thanks for adding to the documentation!

Regards,
Alex

On Tue, Sep 2, 2008 at 11:14 AM, Renaud Richardet <re...@apache.org> wrote:
> hi,
>
> I was also looking for some documentation re ESP, thanks for the
> pointers. I have put a demo ESP file in the wiki:
> http://cwiki.apache.org/confluence/display/SLING/Scripting+variables
>
> HTH, Renaud
>
>
> jc...@proxymit.net schrieb:
>
> Hi,
>
> I've been looking for the Sling ESP reference documentation, but
> google was not really helpful in this. Can somebody point to some doc?
>
> To complement Bertrand's post:
>
> ESP is much like JSP but using JavaScript (Rhino implementation)
> instead of Java as the scripting language.
>
> As such by default an ESP is in script mode, that is everything is
> written to the response as is. The following constructs are available:
>
> <%= expr %>: Evaluates the expression expr and prints the result <%
> javascript %>: Runs the javascript code <%-- comment -->: ESP comment
> removed while preprocessing the script
>
> Just like with JSP, ESP scripts are converted into plain JavaScript
> code on the run, that is a construct like
>
> <% for (var i in list) { %> <p><%= i %>: <%= list[i] %></p> <% } %>
>
> is converted to
>
> for (var i in list) { out.print("\n"); out.print("<p>"); out.print(i);
> out.print(": "); out.print("list[i]"); out.print("</p>\n"); }
>
> (Note I split the line in the loop for readability).
>
> Hope this helps.
>
> Regards Felix
>
> Thanks, Juerg
>



-- 
Alexander Klimetschek
alexander.klimetschek@day.com