Package org.stringtemplate.v4

Examples of org.stringtemplate.v4.ST.render()


            "<users:{u | name: <u>}; separator=\", \">\n" +
            "end\n");
        ST t = group.getInstanceOf("test");
        t.add("users", new ArrayList<Object>());
        String expecting="begin"+newline+"end";
        String result = t.render();
        assertEquals(expecting, result);
    }

    @Test public void testMissingDictionaryValue() throws Exception {
        STGroup group = new STGroup();
View Full Code Here


        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<m.foo>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<Object, Object>());
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }

    @Test public void testMissingDictionaryValue2() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<if(m.foo)>[<m.foo>]<endif>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<Object, Object>());
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }

    @Test public void testMissingDictionaryValue3() throws Exception {
        STGroup group = new STGroup();
View Full Code Here

        STGroup group = new STGroup();
        group.defineTemplate("test", "m", "<if(m.foo)>[<m.foo>]<endif>");
        ST t = group.getInstanceOf("test");
        t.add("m", new HashMap<String, Object>() {{put("foo",null);}});
        String expecting="";
        String result = t.render();
        assertEquals(expecting, result);
    }

  @Test public void TestSeparatorEmittedForEmptyIteratorValue()
    throws IOException
View Full Code Here

    t.impl.dump();
    t.add("a", "Terence");
    t.add("b", "Jim");
    String expecting =
        "  TerenceJim";
    assertEquals(expecting, t.render());
  }

  @Test public void testSimpleIndentOfAttributeList()
      throws Exception
  {
View Full Code Here

    t.add("names", "Sriram");
    String expecting =
        "  Terence"+newline+
        "  Jim"+newline+
        "  Sriram";
    assertEquals(expecting, t.render());
  }

  @Test public void testIndentOfMultilineAttributes()
      throws Exception
  {
View Full Code Here

        "  maniac"+newline+
        "  Jim"+newline+
        "  Sriram"+newline+
        "  is"+newline+
        "  cool";
    assertEquals(expecting, t.render());
  }

  @Test public void testIndentOfMultipleBlankLines()
      throws Exception
  {
View Full Code Here

    t.add("names", "Terence\n\nis a maniac");
    String expecting =
        "  Terence"+newline+
        ""+newline+ // no indent on blank line
        "  is a maniac";
    assertEquals(expecting, t.render());
  }

  @Test public void testIndentBetweenLeftJustifiedLiterals()
      throws Exception
  {
View Full Code Here

        "Before:" +newline+
        "  Terence"+newline+
        "  Jim"+newline+
        "  Sriram"+newline+
        "after";
    assertEquals(expecting, t.render());
  }

  @Test public void testNestedIndent()
      throws Exception
  {
View Full Code Here

            );
        e.add("mine", new String[] { "1", "2", "3" });
        e.add("yours", "a");
        e.add("yours", "b");
        String expecting = "1, b";
        assertEquals(expecting, e.render());
    }

    @Test public void testCombinedOpPrimitiveArray() throws Exception {
        // replace first of yours with first of mine
        ST e = new ST(
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.