public String resolveMessage(MessageKey key) { return key.toString(); }
private String toString(Object o) { Object f = format(o); if (f == null) { return "null"; } else if (f instanceof String) { return (String)f; } else { return o.toString(); } }
@Override public final void emit(EmitContext context, TemplateModel<ASTNode.Template> templateModel) throws TemplateException, IOException { GroovyTemplateEmitter emitter = new GroovyTemplateEmitter(templateModel.getPath().getName()); EmitPhase tcc = new EmitPhase(context); tcc.emit(emitter, templateModel.getModel()); Path.Absolute path = templateModel.getPath(); path = path.as(path.getRawName() + "_", "groovy"); context.createResource(path, emitter.toString()); } }
@Override public void doRender(TemplateRenderContext renderContext) throws TemplateExecutionException, IOException { Binding binding = new BindingImpl(renderContext); // Script script = InvokerHelper.createScript(scriptClass, binding); // try { script.run(); } catch (Exception e) { if (e instanceof IOException) { throw (IOException)e; } else { throw buildRuntimeException(e); } } catch (Throwable e) { if (e instanceof Error) { throw ((Error)e); } throw buildRuntimeException(e); } }
public void appendExpression(String expr) { out.append(expr); locationTable.put(lineNumber, new Foo(pos, expr)); }
public BindingImpl(TemplateRenderContext renderContext) { super(renderContext.getAttributes()); // this.printer = new GroovyPrinter(renderContext); this.renderContext = renderContext; }
public GroovyTemplateStub build(String templateId) { final String script = toString(); return new GroovyTemplateStub(Thread.currentThread().getContextClassLoader(), templateId) { @Override public String getScript(ClassLoader loader, String fqn) { return script; } }; }
@Test public void testSiblingClosures() throws IOException, TemplateException { GroovyTemplateStub template = template("#{title value=a/}#{title value=b/}"); template.getClassName(); }
@Override public final void emit(EmitContext context, TemplateModel<ASTNode.Template> templateModel) throws TemplateException, IOException { GroovyTemplateEmitter emitter = new GroovyTemplateEmitter(templateModel.getPath().getName()); EmitPhase tcc = new EmitPhase(context); tcc.emit(emitter, templateModel.getModel()); Path.Absolute path = templateModel.getPath(); path = path.as(path.getRawName() + "_", "groovy"); context.createResource(path, emitter.toString()); } }
@Override public void doRender(TemplateRenderContext renderContext) throws TemplateExecutionException, IOException { Binding binding = new BindingImpl(renderContext); // Script script = InvokerHelper.createScript(scriptClass, binding); // try { script.run(); } catch (Exception e) { if (e instanceof IOException) { throw (IOException)e; } else { throw buildRuntimeException(e); } } catch (Throwable e) { if (e instanceof Error) { throw ((Error)e); } throw buildRuntimeException(e); } }
public void appendScriptlet(String scriptlet) { out.append(scriptlet); locationTable.put(lineNumber, new Foo(pos, scriptlet)); }
public String resolveMessage(MessageKey key) { return key.toString(); }
private String toString(Object o) { Object f = format(o); if (f == null) { return "null"; } else if (f instanceof String) { return (String)f; } else { return o.toString(); } }
public BindingImpl(TemplateRenderContext renderContext) { super(renderContext.getAttributes()); // this.printer = new GroovyPrinter(renderContext); this.renderContext = renderContext; }
public GroovyTemplateStub build(String templateId) { final String script = toString(); return new GroovyTemplateStub(Thread.currentThread().getContextClassLoader(), templateId) { @Override public String getScript(ClassLoader loader, String fqn) { return script; } }; }
@Test public void testSiblingClosures() throws IOException, TemplateException { GroovyTemplateStub template = template("#{title value=a/}#{title value=b/}"); template.getClassName(); }
public void appendExpression(String expr) { out.append(expr); locationTable.put(lineNumber, new Foo(pos, expr)); }
public void appendScriptlet(String scriptlet) { out.append(scriptlet); locationTable.put(lineNumber, new Foo(pos, scriptlet)); }