Examples of JRubyObjectHandler


Examples of com.github.mustachejava.jruby.JRubyObjectHandler

  @Test
  public void testHash() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("{:test=>'fred'}");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
    writer.close();
    assertEquals("fred", writer.toString());
View Full Code Here

Examples of com.github.mustachejava.jruby.JRubyObjectHandler

  @Test
  public void testObject() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("class Test\ndef test()\n  \"fred\"\nend\nend\nTest.new\n");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
    writer.close();
    assertEquals("fred", writer.toString());
View Full Code Here

Examples of com.github.mustachejava.jruby.JRubyObjectHandler

  @Test
  public void testArray() throws IOException {
    ScriptingContainer sc = new ScriptingContainer();
    Object context = sc.runScriptlet("class Test\ndef test()\n  [\"fred\",\"fred\"]\nend\nend\nTest.new\n");
    DefaultMustacheFactory mf = new DefaultMustacheFactory();
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile(new StringReader("{{#test}}{{.}}{{/test}}"), "test");
    Writer writer = new StringWriter();
    writer = m.execute(writer, context);
    writer.close();
    assertEquals("fredfred", writer.toString());
View Full Code Here

Examples of com.github.mustachejava.jruby.JRubyObjectHandler

  @Test
  public void testComplex() throws IOException {
    Object context = makeComplex();
    DefaultMustacheFactory mf = new DefaultMustacheFactory(root);
    mf.setObjectHandler(new JRubyObjectHandler());
    Mustache m = mf.compile("complex.html");
    Writer writer = complextest(m, context);
    assertEquals(getContents(root, "complex.txt"), writer.toString());
  }
View Full Code Here

Examples of com.github.mustachejava.jruby.JRubyObjectHandler

    if (skip()) return;
    System.out.println("complex.html evaluations per millisecond:");
    for (int i = 0; i < 3; i++) {
      {
        DefaultMustacheFactory cf = new DefaultMustacheFactory();
        cf.setObjectHandler(new JRubyObjectHandler());
        Mustache m = cf.compile("complex.html");
        Object context = makeComplex();
        assertEquals(getContents(root, "complex.txt"), complextest(m, context).toString());
        long start = System.currentTimeMillis();
        int total = 0;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.