Examples of STGroupDir


Examples of org.stringtemplate.v4.STGroupDir

  @Test public void testSubSubdir() throws Exception {
        // /randomdir/a and /randomdir/subdir/b
        String dir = getRandomDir();
    writeFile(dir,              "a.st", "a(x) ::= <<foo>>");
    writeFile(dir+"/sub1/sub2", "b.st", "b() ::= \"bar\"");
        STGroup group = new STGroupDir(dir);
        ST st1 = group.getInstanceOf("a");
        ST st2 = group.getInstanceOf("/sub1/sub2/b");
        String expected = "foobar";
        String result = st1.render()+st2.render();
        assertEquals(expected, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

    writeFile(dir, "a.st", "a(x) ::= <<foo>>");
        String groupFile =
            "b() ::= \"bar\"\n"+
            "c() ::= \"duh\"\n";
        writeFile(dir, "subdir/group.stg", groupFile);
        STGroup group = new STGroupDir(dir);
        ST st1 = group.getInstanceOf("a");
        ST st2 = group.getInstanceOf("subdir/group/b");
        ST st3 = group.getInstanceOf("subdir/group/c");
        String expected = "foobarduh";
        String result = st1.render()+st2.render()+st3.render();
        assertEquals(expected, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

        String dir = getRandomDir();
        String a = "a() ::= << <b()> >>\n";
        String b = "b(x=\"foo\") ::= \"<x>\"\n";
        writeFile(dir, "a.st", a);
        writeFile(dir, "b.st", b);
        STGroup group = new STGroupDir(dir);
        ST st = group.getInstanceOf("a");
        String expected = " foo ";
        String result = st.render();
        assertEquals(expected, result);
    }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

        String groupFile =
            "b() ::= \"group file b\"\n";
        writeFile(dir, "group.stg", groupFile);

        STGroup group1 = new STGroupDir(dir);
        ST st = group1.getInstanceOf("group/a"); // can't see
        assertEquals(null, st);
    }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

      "a(x) ::= <<foo>>\n";
    String b =
      "b() ::= <<bar>>\n";
    writeFile(dir, "a.st", a);
    writeFile(dir, "b.st", b);
    STGroup group = new STGroupDir(dir);
    group.load(); // force load
    ST st = group.getInstanceOf("a");
    int originalHashCode = System.identityHashCode(st);
    group.unload(); // blast cache
    st = group.getInstanceOf("a");
    int newHashCode = System.identityHashCode(st);
    assertEquals(originalHashCode==newHashCode, false); // diff objects
    String expected = "foo";
    String result = st.render();
    assertEquals(expected, result);
    st = group.getInstanceOf("b");
    expected = "bar";
    result = st.render();
    assertEquals(expected, result);
  }
View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

     * @param account the user account that has had its password reset
     * @param locale the locale of the user who reset the password
     * @return The message body as a string.
     */
    private String formatBody(URL resetUrl, ILocalAccountPerson account, Locale locale) {
        final STGroup group = new STGroupDir(templateDir, '$', '$');
        final ST template = group.getInstanceOf(templateName);

        String name = findDisplayNameFromLocalAccountPerson(account);
        template.add("displayName", name);
        template.add("url", resetUrl.toString());

View Full Code Here

Examples of org.stringtemplate.v4.STGroupDir

  private STGroup group;
  private String path;

  public StringTemplateEngine(String templateFolder) {
    path = templateFolder;
    group = new STGroupDir(templateFolder);
  }
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.