Search in sources :

Example 6 with CompiledTemplate

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());
}
Also used : OutputStream(java.io.OutputStream) CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Aggregations

CompiledTemplate (org.mvel2.templates.CompiledTemplate)6 ParserContext (org.mvel2.ParserContext)2 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 Reader (java.io.Reader)1 TreeMap (java.util.TreeMap)1 Message (org.apache.camel.Message)1 MapVariableResolverFactory (org.mvel2.integration.impl.MapVariableResolverFactory)1 TemplateCompiler (org.mvel2.templates.TemplateCompiler)1 TemplateError (org.mvel2.templates.TemplateError)1 Node (org.mvel2.templates.res.Node)1 TestPluginNode (org.mvel2.tests.templates.tests.res.TestPluginNode)1