use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.
the class SecurityManagerTestCase method classAccess.
@Test
public void classAccess() throws Exception {
JetTemplate template = engine.createTemplate("${new Date()}");
UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
template.render(new JetContext(), out);
}
use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.
the class SourceCodeTest method foreachArray.
@Test
public void foreachArray() {
JetContext context = new JetContext();
context.put("applications", new String[][] { { "1", "2", "3" }, { "a", "b", "c" } });
StringBuilder sb = new StringBuilder();
sb.append("#for(String[] apps: applications)\n");
sb.append(" #for(String app: apps)\n");
sb.append(" ${app}\n");
sb.append(" #end\n");
sb.append("#end\n");
JetTemplate template = engine.createTemplate(sb.toString());
UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
template.render(context, out);
Assert.assertEquals(" 1\n 2\n 3\n a\n b\n c\n", out.toString());
}
use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.
the class SourceCodeTest method plain.
@Test
public void plain() {
JetTemplate template = engine.createTemplate("你好");
UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
template.render(new JetContext(), out);
Assert.assertEquals("你好", out.toString());
}
use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.
the class SourceCodeTest method expression.
@Test
public void expression() {
JetTemplate template = engine.createTemplate("${1+2*3}");
UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
template.render(new JetContext(), out);
Assert.assertEquals("7", out.toString());
}
use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.
the class TagInForeachTest method tagInFor.
@Test
public void tagInFor() {
String source = "#for(int i: iterator(1,9))#tag testTag()${i}#end#end";
JetTemplate template = engine.createTemplate(source);
UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
JetContext context = new JetContext();
template.render(context, out);
Assert.assertEquals(out.toString(), "123456789");
}
Aggregations