use of com.google.template.soy.jbcsrc.restricted.MethodRef in project closure-templates by google.
the class BasicEscapeDirective method applyForJbcSrc.
@Override
public SoyExpression applyForJbcSrc(JbcSrcPluginContext context, SoyExpression value, List<SoyExpression> args) {
MethodRef sanitizerMethod = javaSoyValueSanitizer;
if (sanitizerMethod == null) {
// lazily allocated
sanitizerMethod = MethodRef.create(Sanitizers.class, name.substring(1), SoyValue.class).asNonNullable();
javaSoyValueSanitizer = sanitizerMethod;
}
// about the content kind of the string.
return SoyExpression.forString(sanitizerMethod.invoke(value.box()));
}
use of com.google.template.soy.jbcsrc.restricted.MethodRef 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);
}
}
Aggregations