Hi Janandith, On Sat, May 31, 2008 at 10:46 AM, janandith jayawardena <[EMAIL PROTECTED]> wrote:
> ...Scala has an interpreter which I intend to call in the eval method of my > script engine to run scripts.... I had a quick look at the Scala interpreter class [1], and it is probably what you need. However, the comments there say "the interpret() method executes one line of Scala code at the request of the user", so to run scripts you'll probably need to use the compile() method first. This is similar to JSP where scripts are compiled before running them, as opposed to Rhino/javascript which is actually an interpreter. Having a first version of the Scala engine for Sling that uses interpret() and as such allows only one-line scripts would be ok though: that would be a concrete step in the right direction. > ...To check whether it's loading I did the following,... > <html> > <body> > <script type="text/scala" name="scala"> > document.write("<p><b>Hello World!<\/b>")... As Felix says, that will not work as the above is not Scala code. We probably want something like the above for the final version, but that will probably require writing filtering code to convert such a template to Scala statements. As a first step, being able to run a script that contains something extremely simple like "2+4" would be ok. IMHO you're currently struggling with two distinct problems: 1) How to integrate a new scripting language into Sling 2) How to run scripts/templates with Scala. To progress, I really think you should tackle both problems separately and, as suggested before, solve 1) by creating a do-nothing scripting engine that just spits out the script as is, without interpreting it. You could then forget about that problem and start replacing the do-nothing engine by the Scala compiler, which is a totally different problem. Hope this helps, -Bertrand [1] https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/compiler/scala/tools/nsc/Interpreter.scala