You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Lars Trieloff <la...@trieloff.net> on 2007/10/19 13:44:30 UTC
[microsling] Making the Resource in Javascript a little bit more JSON-like
Hi,
I started playing with microsling yesterday and found so far two
itches in the Javascript template approach used by microsling that I
would like to scatch:
1) Syntax highlighting for ESP: http://weblogs.goshaky.com/weblogs/
lars/entry/esp_javascript_template_language_syntax
2) Making the Javascript objects used in ESP-templates like resource
and resource.item a little bit easier to handle by wrapping them in
ScriptableObjects. The ESP example could then be simplified to:
<%-- microsling ESP template example, store this as html.esp --%>
<html>
<body>
<p>This page is generated from an ESP template!</p>
<h1><%= resource.uri %></h1>
<%
for each (var p in resource.item.properties) {
%>
<p>
<%= p.name %>
=
<strong><%= p.string %></strong>
</p>
<%
}
%>
</body>
</html>
Other ways of accessing a property could be:
resource.item.properties.foo
resource.item.properties["foo"]
resource.item.properties[1]
and the same API could apply to children. The idea is to expose the
Resource (and the wrapped Node) as a JSON object that can be
processed easily.
regards,
Lars
Re: [microsling] Making the Resource in Javascript a little bit
more JSON-like
Posted by Felix Meschberger <fm...@gmail.com>.
Very good news. Looking forward to it !
Regards
Felix
Am Samstag, den 20.10.2007, 18:59 +0200 schrieb Lars Trieloff:
> >
> > Very true. This would in fact be some simplification, though the JCR
> > purist will of course not like it :-)
> > I would invite you to contribute such host objects. What do you
> > think ?
> > Unfortunately, it has been some years (yes it was 2001) since I did my
> > last ScriptObject implementation ...
> >
>
> Great. I will write these objects and keep all the JCR methods, so
> the JCR-purists can use their Java-API.
>
Re: [microsling] Making the Resource in Javascript a little bit more JSON-like
Posted by Lars Trieloff <la...@trieloff.net>.
>
> Very true. This would in fact be some simplification, though the JCR
> purist will of course not like it :-)
> I would invite you to contribute such host objects. What do you
> think ?
> Unfortunately, it has been some years (yes it was 2001) since I did my
> last ScriptObject implementation ...
>
Great. I will write these objects and keep all the JCR methods, so
the JCR-purists can use their Java-API.
Re: [microsling] Making the Resource in Javascript a little bit
more JSON-like
Posted by Felix Meschberger <fm...@gmail.com>.
Hi Lars,
Am Freitag, den 19.10.2007, 13:44 +0200 schrieb Lars Trieloff:
> 1) Syntax highlighting for ESP: http://weblogs.goshaky.com/weblogs/
> lars/entry/esp_javascript_template_language_syntax
Cool. Just one minor note: ESP is not actually inspired by JSTE as it is
used in Day's Communiqué product since the year 2001 :-)
> 2) Making the Javascript objects used in ESP-templates like resource
> and resource.item a little bit easier to handle by wrapping them in
> ScriptableObjects. The ESP example could then be simplified to:
Very true. This would in fact be some simplification, though the JCR
purist will of course not like it :-)
I would invite you to contribute such host objects. What do you think ?
Unfortunately, it has been some years (yes it was 2001) since I did my
last ScriptObject implementation ...
Regards
Felix