Hi Keith,

That syntax seems very similar to E4X which creates DOM nodes. With my approach, I can create plain text templates too.

/ henrik

Keith wrote:
On Dec 4, 7:33 pm, Henrik Lindqvist <[email protected]>
wrote:
Hi,

I'am planning on using Rhino as a replacement for JSP, soo I've hacked
the parser adding a optional feature to enable a similar syntax:

-- cut --
%><h1>Title</h1>
<ul>
<% for (var i = 1; i <= 10; i++) { %>
<li>Item #<%= i %></li>
<% } %>
</ul>
-- cut --

Now some questions:

1. Is anyone else interested is such a feature?

2. Would such a feature, properly implemented, ever be accepted to the
main trunk of the Rhino source?

3. If yes. Any tips on how to correctly implement this? I've now just
added an additional token '%>template text<%', the parser then creates
AST nodes to call a "print" function with the template text and '<%='
expression as arguments. As said, currently a quick hack.

/ henrik

Wow... I was looking forward for such a thing in Rhino. However, not
being a Rhino expert I ended up using println() statements. This will
be a welcome addition. Wouldn't borrowing syntax from XQuery instead
of JSP be much neater? Some thing like:


function main()
{
return <html>
<body>
 for (var i=0; i<10; ++i)
   <div>{i}</div>
</body>
</html>
}

var xhtmlNode=main();
{xhtmlNode}
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to