Package org.stringtemplate.v4

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


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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

    @Test public void testReUseOfRestResult() throws Exception {
        String templates =
            "a(names) ::= \"<b(rest(names))>\""+newline+
View Full Code Here

        writeFile(tmpdir, "t.stg", templates);
        STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
        ST e = group.getInstanceOf("a");
        e.add("names", new int[] { 0, 1 });
        String expecting = "1, 1";
        assertEquals(expecting, e.render());
    }

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

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

    @Test public void testLastOpList() throws Exception {
        ST e = new ST(
                "<last(names)>"
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.