Search in sources :

Example 21 with SoyExpression

use of com.google.template.soy.jbcsrc.restricted.SoyExpression in project closure-templates by google.

the class BasicEscapeDirective method applyForJbcSrcStreaming.

/**
 * Default implementation for {@link Streamable}.
 *
 * <p>Subclasses can simply add {@code implements Streamable} if they have an implementation in
 * Sanitizers.<name>Streaming. If they don't, this method will throw while trying to find it.
 */
public final AppendableAndOptions applyForJbcSrcStreaming(JbcSrcPluginContext context, Expression delegateAppendable, List<SoyExpression> args) {
    MethodRef sanitizerMethod = javaStreamingSanitizer;
    if (sanitizerMethod == null) {
        // lazily allocated
        sanitizerMethod = MethodRef.create(Sanitizers.class, name.substring(1) + "Streaming", LoggingAdvisingAppendable.class).asNonNullable();
        javaStreamingSanitizer = sanitizerMethod;
    }
    Expression streamingSanitizersExpr = sanitizerMethod.invoke(delegateAppendable);
    if (isCloseable()) {
        return AppendableAndOptions.createCloseable(streamingSanitizersExpr);
    } else {
        return AppendableAndOptions.create(streamingSanitizersExpr);
    }
}
Also used : MethodRef(com.google.template.soy.jbcsrc.restricted.MethodRef) SoyExpression(com.google.template.soy.jbcsrc.restricted.SoyExpression) Expression(com.google.template.soy.jbcsrc.restricted.Expression)

Aggregations

SoyExpression (com.google.template.soy.jbcsrc.restricted.SoyExpression)21 Expression (com.google.template.soy.jbcsrc.restricted.Expression)8 Statement (com.google.template.soy.jbcsrc.restricted.Statement)5 SoyType (com.google.template.soy.types.SoyType)4 Label (org.objectweb.asm.Label)4 Scope (com.google.template.soy.jbcsrc.TemplateVariableManager.Scope)3 Variable (com.google.template.soy.jbcsrc.TemplateVariableManager.Variable)3 LegacyObjectMapType (com.google.template.soy.types.LegacyObjectMapType)3 MapType (com.google.template.soy.types.MapType)3 ArrayList (java.util.ArrayList)3 ExprRootNode (com.google.template.soy.exprtree.ExprRootNode)2 IfBlock (com.google.template.soy.jbcsrc.ControlFlow.IfBlock)2 SoyNode (com.google.template.soy.soytree.SoyNode)2 UnknownType (com.google.template.soy.types.UnknownType)2 SoyString (com.google.template.soy.data.restricted.SoyString)1 FunctionNode (com.google.template.soy.exprtree.FunctionNode)1 BasicExpressionCompiler (com.google.template.soy.jbcsrc.ExpressionCompiler.BasicExpressionCompiler)1 CodeBuilder (com.google.template.soy.jbcsrc.restricted.CodeBuilder)1 MethodRef (com.google.template.soy.jbcsrc.restricted.MethodRef)1 AppendableAndOptions (com.google.template.soy.jbcsrc.restricted.SoyJbcSrcPrintDirective.Streamable.AppendableAndOptions)1