1 25 26 package org.snipsnap.render.macro; 27 28 import org.python.util.PythonInterpreter; 29 import org.snipsnap.render.macro.parameter.SnipMacroParameter; 30 31 import java.io.IOException ; 32 import java.io.Writer ; 33 import java.util.Map ; 34 35 42 43 public class ScriptMacro extends SnipPreserved { 44 private Map filters; 45 46 public ScriptMacro() { 47 } 48 49 public String getName() { 50 return "script"; 51 } 52 53 public String getDescription() { 54 return "Execute a piece of python source code."; 55 } 56 57 public void execute(Writer writer, SnipMacroParameter params) 58 throws IllegalArgumentException , IOException { 59 60 PythonInterpreter interp = 61 new PythonInterpreter(); 62 63 interp.setOut(writer); 64 interp.set("snip", params.getSnipRenderContext().getSnip()); 65 interp.exec(params.getContent()); 66 } 67 } 68 | Popular Tags |