Package juzu.impl.template.spi.juzu.dialect.gtmpl

Examples of juzu.impl.template.spi.juzu.dialect.gtmpl.GroovyTemplateStub


/** @author <a href="mailto:julien.viet@exoplatform.com">Julien Viet</a> */
public class TemplateBuilderTestCase extends AbstractTemplateTestCase {

  @Test
  public void testFoo() throws Exception {
    GroovyTemplateStub s = template("a<%=foo%>c");
    s.init();
    StringWriter out = new StringWriter();
    new TemplateRenderContext(s, Collections.<String, Object>singletonMap("foo", "b")).render(OutputStream.create(Tools.UTF_8, out));
    assertEquals("abc", out.toString());
  }
View Full Code Here


    assertEquals("abc", out.toString());
  }

  @Test
  public void testCarriageReturn() throws Exception {
    GroovyTemplateStub s = template("a\r\nb");
    s.init();
    StringWriter out = new StringWriter();
    new TemplateRenderContext(s, Collections.<String, Object>emptyMap()).render(OutputStream.create(Tools.UTF_8, out));
    assertEquals("a\nb", out.toString());
  }
View Full Code Here

      emitPhase.emit(generator, templateModel.getModel());
    }
    catch (juzu.impl.template.spi.juzu.ast.ParseException e) {
      throw failure(e);
    }
    GroovyTemplateStub stub = generator.build(fqn.toString());
    stub.init();
    return stub;
  }
View Full Code Here

    render(text, attributes, locale, out);
    return out.toString();
  }

  public void render(String text, Map<String, Object> attributes, Locale locale, Appendable appendable) throws IOException, TemplateExecutionException, TemplateException {
    GroovyTemplateStub template = template(text);
    TemplateRenderContext renderContext = new TemplateRenderContext(template, null, attributes, locale);
    OutputStream adapter = OutputStream.create(Tools.UTF_8, appendable);
    renderContext.render(adapter);
    final AtomicReference<IOException> ios = new AtomicReference<IOException>();
    adapter.close(new Thread.UncaughtExceptionHandler() {
View Full Code Here

    }
  }

  @Test
  public void testSiblingClosures() throws IOException, TemplateException {
    GroovyTemplateStub template = template("#{title value=a/}#{title value=b/}");
    template.getClassName();
  }
View Full Code Here

  @Test
  public void testWriterAccess() throws Exception {
    out = null;
    Writer writer = new StringWriter();
    GroovyTemplateStub template = template("<% " + TemplateRenderingTestCase.class.getName() + ".out = out; %>");
    new TemplateRenderContext(template).render(OutputStream.create(Tools.UTF_8, writer));
    assertNotNull(out);
  }
View Full Code Here

    new TemplateRenderContext(template).render(OutputStream.create(Tools.UTF_8, writer));
    assertNotNull(out);
  }

  private void assertLineNumber(int expectedLineNumber, String expectedText, String script) throws IOException, TemplateException {
    GroovyTemplateStub template = template(script);
    try {
      new TemplateRenderContext(template).render(OutputStream.create());
      fail();
    }
    catch (TemplateExecutionException t) {
      assertEquals(expectedText, t.getText());
      assertEquals(expectedLineNumber, (Object)t.getLineNumber());
      StackTraceElement scriptElt = null;
      for (StackTraceElement elt : t.getCause().getStackTrace()) {
        if (elt.getClassName().equals(template.getClassName())) {
          scriptElt = elt;
          break;
        }
      }
      assertEquals(expectedLineNumber, scriptElt.getLineNumber());
View Full Code Here

TOP

Related Classes of juzu.impl.template.spi.juzu.dialect.gtmpl.GroovyTemplateStub

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.