use of org.mvel2.templates.CompiledTemplate in project mvel by mikebrock.
the class TemplateTests method testOutputStream1.
public void testOutputStream1() {
final StringBuilder sb = new StringBuilder();
OutputStream outstream = new OutputStream() {
@Override
public void write(int b) throws IOException {
sb.append((char) b);
}
};
String template = "@foreach{item:['foo','far']}@{item}@end{}";
CompiledTemplate compiled = TemplateCompiler.compileTemplate(template);
TemplateRuntime.execute(compiled, new HashMap(), outstream);
assertEquals("foofar", sb.toString());
}
use of org.mvel2.templates.CompiledTemplate in project mvel by mikebrock.
the class TemplateTests method testPluginNode.
public void testPluginNode() {
Map<String, Class<? extends Node>> plugins = new HashMap<String, Class<? extends Node>>();
plugins.put("testNode", TestPluginNode.class);
TemplateCompiler compiler = new TemplateCompiler("Foo:@testNode{}!!", plugins);
CompiledTemplate compiled = compiler.compile();
assertEquals("Foo:THIS_IS_A_TEST!!", TemplateRuntime.execute(compiled));
}
use of org.mvel2.templates.CompiledTemplate in project mvel by mvel.
the class TemplateTests method testOutputStream1.
public void testOutputStream1() {
final StringBuilder sb = new StringBuilder();
OutputStream outstream = new OutputStream() {
@Override
public void write(int b) throws IOException {
sb.append((char) b);
}
};
String template = "@foreach{item:['foo','far']}@{item}@end{}";
CompiledTemplate compiled = TemplateCompiler.compileTemplate(template);
TemplateRuntime.execute(compiled, new HashMap(), outstream);
assertEquals("foofar", sb.toString());
}
Aggregations