1 package org.sapia.gumby.script.pnuts; 2 3 import org.sapia.gumby.RenderContext; 4 import org.sapia.gumby.script.Script; 5 import org.sapia.gumby.script.ScriptConsts; 6 7 import pnuts.compiler.Compiler; 8 import pnuts.lang.Context; 9 import pnuts.lang.ParseException; 10 import pnuts.lang.Pnuts; 11 12 27 public class PnutsScript implements Script, ScriptConsts { 28 29 private Pnuts _pn; 30 31 PnutsScript(String script) throws ParseException { 32 Compiler comp = new Compiler (); 33 _pn = comp.compile(script); 34 } 35 36 40 public Object execute(RenderContext renderContext, Object [] args) 41 throws Exception { 42 Context ctx = new Context(); 43 ctx.set(KEY_CONTEXT, renderContext); 44 ctx.set(KEY_ARGS, args); 45 return _pn.run(ctx); 46 } 47 48 } 49 | Popular Tags |