Search in sources :

Example 1 with StackDelimiterResolverFactory

use of org.mvel2.integration.impl.StackDelimiterResolverFactory in project mvel by mvel.

the class CompiledNamedIncludeNode method eval.

public Object eval(TemplateRuntime runtime, TemplateOutputStream appender, Object ctx, VariableResolverFactory factory) {
    factory = new StackDelimiterResolverFactory(factory);
    if (cPreExpression != null) {
        MVEL.executeExpression(cPreExpression, ctx, factory);
    }
    if (next != null) {
        String namedTemplate = MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class);
        CompiledTemplate ct = runtime.getNamedTemplateRegistry().getNamedTemplate(namedTemplate);
        if (ct == null)
            throw new TemplateError("named template does not exist: " + namedTemplate);
        return next.eval(runtime, appender.append(String.valueOf(TemplateRuntime.execute(ct, ctx, factory, runtime.getNamedTemplateRegistry()))), ctx, factory);
    // return next.eval(runtime,
    // appender.append(String.valueOf(TemplateRuntime.execute(runtime.getNamedTemplateRegistry().getNamedTemplate(MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class)), ctx, factory))), ctx, factory);
    } else {
        return appender.append(String.valueOf(TemplateRuntime.execute(runtime.getNamedTemplateRegistry().getNamedTemplate(MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class)), ctx, factory, runtime.getNamedTemplateRegistry())));
    }
}
Also used : StackDelimiterResolverFactory(org.mvel2.integration.impl.StackDelimiterResolverFactory) TemplateError(org.mvel2.templates.TemplateError) CompiledTemplate(org.mvel2.templates.CompiledTemplate)

Aggregations

StackDelimiterResolverFactory (org.mvel2.integration.impl.StackDelimiterResolverFactory)1 CompiledTemplate (org.mvel2.templates.CompiledTemplate)1 TemplateError (org.mvel2.templates.TemplateError)1