Package org.stringtemplate.v4

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


    e.add("names", "Ter");
    e.add("names", "Tom");
    e.add("phones", "1");
    e.add("phones", "2");
    String expecting = "Ter";
    assertEquals(expecting, e.render());
  }

  @Test public void testFirstWithListOfMaps() throws Exception {
    org.stringtemplate.v4.ST e = new org.stringtemplate.v4.ST(
        "<first(maps).Ter>"
View Full Code Here


        ST e = new org.stringtemplate.v4.ST(
                "<trim(name)>"
            );
        e.add("name", " Ter  \n");
        String expecting = "Ter";
        assertEquals(expecting, e.render());
    }

    @Test public void testStrlen() throws Exception {
        org.stringtemplate.v4.ST e = new org.stringtemplate.v4.ST(
                "<strlen(name)>"
View Full Code Here

        ST e = new ST(
                "<reverse(names); separator=\", \">"
            );
        e.add("names", Arrays.asList("Ter", "Tom", "Sriram"));
        String expecting = "Sriram, Tom, Ter";
        assertEquals(expecting, e.render());
    }

    @Test public void testReverseArray() throws Exception {
        ST e = new ST(
                "<reverse(names); separator=\", \">"
View Full Code Here

        ST e = new ST(
                "<reverse(names); separator=\", \">"
            );
        e.add("names", new String[] { "Ter", "Tom", "Sriram" });
        String expecting = "Sriram, Tom, Ter";
        assertEquals(expecting, e.render());
    }

    @Test public void testReversePrimitiveArray() throws Exception {
        ST e = new ST(
                "<reverse(names); separator=\", \">"
View Full Code Here

        ST e = new ST(
                "<reverse(names); separator=\", \">"
            );
        e.add("names", new int[] { 0, 1, 2 });
        String expecting = "2, 1, 0";
        assertEquals(expecting, e.render());
    }

}
View Full Code Here

        List<String> names = new ArrayList<String>() {
            {add("Ter"); add("Tom");}
        };
        st.add("names", names);
        String expected = "Ter";
        String result = st.render();
        assertEquals(expected, result);
    }

  @Test public void testLength() throws Exception {
    String template = "<length(names)>";
View Full Code Here

        ST e = new ST(
                "<first(names)>"
            );
        e.add("names", Arrays.asList("Ter", "Tom", "Sriram"));
        String expecting = "Ter";
        assertEquals(expecting, e.render());
    }

    @Test public void testFirstOpArray() throws Exception {
        ST e = new ST(
                "<first(names)>"
View Full Code Here

        ST e = new ST(
                "<first(names)>"
            );
        e.add("names", new String[] { "Ter", "Tom", "Sriram" });
        String expecting = "Ter";
        assertEquals(expecting, e.render());
    }

    @Test public void testFirstOpPrimitiveArray() throws Exception {
        ST e = new ST(
                "<first(names)>"
View Full Code Here

        ST e = new ST(
                "<first(names)>"
            );
        e.add("names", new int[] { 0, 1, 2 });
        String expecting = "0";
        assertEquals(expecting, e.render());
    }

    @Test public void testTruncOp() throws Exception {
        org.stringtemplate.v4.ST e = new org.stringtemplate.v4.ST(
                "<trunc(names); separator=\", \">"
View Full Code Here

        ST e = new ST(
                "<trunc(names); separator=\", \">"
            );
        e.add("names", Arrays.asList("Ter", "Tom", "Sriram"));
        String expecting = "Ter, Tom";
        assertEquals(expecting, e.render());
    }

    @Test public void testTruncOpArray() throws Exception {
        ST e = new ST(
                "<trunc(names); separator=\", \">"
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.