public abstract class BasicEscapeDirective extends Object implements SoyJavaPrintDirective, SoyLibraryAssistedJsSrcPrintDirective, SoyPySrcPrintDirective, SoyJbcSrcPrintDirective
Sanitizers in java, soyutils.js or the
closure equivalent in JavaScript, and sanitize.py in Python.
See GenerateSoyUtilsEscapingDirectiveCode which
creates the JS code that backs escaping directives, and GeneratePySanitizeEscapingDirectiveCode which creates the
Python backing code.
SoyJbcSrcPrintDirective.Streamable| Constructor and Description |
|---|
BasicEscapeDirective(String name) |
| Modifier and Type | Method and Description |
|---|---|
SoyValue |
applyForJava(SoyValue value,
List<SoyValue> args)
Applies this directive on the given value.
|
SoyExpression |
applyForJbcSrc(JbcSrcPluginContext context,
SoyExpression value,
List<SoyExpression> args)
Applies this directive on the given value.
|
SoyJbcSrcPrintDirective.Streamable.AppendableAndOptions |
applyForJbcSrcStreaming(JbcSrcPluginContext context,
Expression delegateAppendable,
List<SoyExpression> args)
Default implementation for
Streamable. |
JsExpr |
applyForJsSrc(JsExpr value,
List<JsExpr> args)
Applies this directive on the given string value.
|
PyExpr |
applyForPySrc(PyExpr value,
List<PyExpr> args)
Applies this directive on the given string value.
|
protected abstract String |
escape(SoyValue value)
Performs the actual escaping.
|
String |
getName()
The name of the Soy directive that this instance implements.
|
com.google.common.collect.ImmutableSet<String> |
getRequiredJsLibNames()
Returns a list of Closure library names to require when this directive is used.
|
Set<Integer> |
getValidArgsSizes()
Gets the set of valid args list sizes.
|
protected boolean |
isCloseable()
Returns whether or not the streaming version of this directive is closeable.
|
boolean |
shouldCancelAutoescape()
Returns whether the appearance of this directive on a 'print' tag should cancel autoescape for
that 'print' tag.
|
public BasicEscapeDirective(String name)
name - E.g. |escapeUri.public final String getName()
getName in interface SoyPrintDirectivepublic final Set<Integer> getValidArgsSizes()
SoyPrintDirectivegetValidArgsSizes in interface SoyPrintDirectivepublic final boolean shouldCancelAutoescape()
SoyPrintDirectiveshouldCancelAutoescape in interface SoyPrintDirectiveprotected boolean isCloseable()
The default is false, override this to change it to true;
public SoyValue applyForJava(SoyValue value, List<SoyValue> args)
SoyJavaPrintDirectiveapplyForJava in interface SoyJavaPrintDirectivevalue - The input to the directive. This is not necessarily a string. If a directive only
applies to string inputs, then it should first call coerceToString() on this input
value.args - The directive's arguments, if any (often none).StringData or SanitizedContent.public JsExpr applyForJsSrc(JsExpr value, List<JsExpr> args)
SoyJsSrcPrintDirectiveImportant note when implementing this method: The string value may not yet have been coerced
to a string. You may need to explicitly coerce it to a string using the JS function String().
applyForJsSrc in interface SoyJsSrcPrintDirectivevalue - The value to apply the directive on. This value may not yet have been coerced to a
string.args - The directive's arguments, if any (usually none).public com.google.common.collect.ImmutableSet<String> getRequiredJsLibNames()
SoyLibraryAssistedJsSrcPrintDirectiveNote: Return the raw Closure library names, Soy will wrap them in goog.require for you.
getRequiredJsLibNames in interface SoyLibraryAssistedJsSrcPrintDirectivepublic PyExpr applyForPySrc(PyExpr value, List<PyExpr> args)
SoyPySrcPrintDirectiveImportant note when implementing this method: The string value may not yet have been coerced
to a string. You may need to explicitly coerce it to a string expression using PyExpr.toPyString().
applyForPySrc in interface SoyPySrcPrintDirectivevalue - The value to apply the directive on. This value may not yet have been coerced to a
string.args - The directive's arguments, if any (usually none).public SoyExpression applyForJbcSrc(JbcSrcPluginContext context, SoyExpression value, List<SoyExpression> args)
SoyJbcSrcPrintDirectiveImportant note when implementing this method: The value may not yet have been coerced to a
string. You may need to explicitly coerce it to a string using the SoyExpression.coerceToString().
applyForJbcSrc in interface SoyJbcSrcPrintDirectivevalue - The value to apply the directive on. This value may not yet have been coerced to a
string.args - The directive's arguments, if any (usually none).public final SoyJbcSrcPrintDirective.Streamable.AppendableAndOptions applyForJbcSrcStreaming(JbcSrcPluginContext context, Expression delegateAppendable, List<SoyExpression> args)
Streamable.
Subclasses can simply add implements Streamable if they have an implementation in
Sanitizers.