public class GenCallCodeUtils extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
GenCallCodeUtils(Map<String,SoyJsSrcPrintDirective> soyJsSrcDirectivesMap,
JsExprTranslator jsExprTranslator,
DelTemplateNamer delTemplateNamer,
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
GenJsExprsVisitor.GenJsExprsVisitorFactory genJsExprsVisitorFactory) |
| Modifier and Type | Method and Description |
|---|---|
JsExpr |
genCallExpr(CallNode callNode,
Deque<Map<String,JsExpr>> localVarTranslations,
TemplateAliases templateAliases,
ErrorReporter errorReporter)
Generates the JS expression for a given call.
|
JsExpr |
genObjToPass(CallNode callNode,
Deque<Map<String,JsExpr>> localVarTranslations,
TemplateAliases templateAliases,
ErrorReporter errorReporter)
Generates the JS expression for the object to pass in a given call.
|
protected JsExpr |
maybeWrapContent(CallParamContentNode node,
JsExpr valueJsExpr)
If the param node had a content kind specified, it was autoescaped in the
corresponding context.
|
@Inject protected GenCallCodeUtils(Map<String,SoyJsSrcPrintDirective> soyJsSrcDirectivesMap, JsExprTranslator jsExprTranslator, DelTemplateNamer delTemplateNamer, IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor, GenJsExprsVisitor.GenJsExprsVisitorFactory genJsExprsVisitorFactory)
jsExprTranslator - Instance of JsExprTranslator to use.isComputableAsJsExprsVisitor - The IsComputableAsJsExprsVisitor to be used.genJsExprsVisitorFactory - Factory for creating an instance of GenJsExprsVisitor.public JsExpr genCallExpr(CallNode callNode, Deque<Map<String,JsExpr>> localVarTranslations, TemplateAliases templateAliases, ErrorReporter errorReporter)
Important: If there are CallParamContentNode children whose contents are not computable as JS expressions, then this function assumes that, elsewhere, code has been generated to define their respective 'param<n>' temporary variables.
Here are five example calls:
{call some.func data="all" /}
{call some.func data="$boo.foo" /}
{call some.func}
{param goo = $moo /}
{/call}
{call some.func data="$boo"}
{param goo}Blah{/param}
{/call}
{call some.func}
{param goo}
{for $i in range(3)}{$i}{/for}
{/param}
{/call}
Their respective generated calls might be the following:
some.func(opt_data)
some.func(opt_data.boo.foo)
some.func({goo: opt_data.moo})
some.func(soy.$$assignDefaults({goo: 'Blah'}, opt_data.boo))
some.func({goo: param65})
Note that in the last case, the param content is not computable as JS expressions, so we assume
that code has been generated to define the temporary variable 'param<n>'.callNode - The call to generate code for.localVarTranslations - The current stack of replacement JS expressions for the local
variables (and foreach-loop special functions) current in scope.templateAliases - A mapping of fully qualified calls to a variable in scope.public JsExpr genObjToPass(CallNode callNode, Deque<Map<String,JsExpr>> localVarTranslations, TemplateAliases templateAliases, ErrorReporter errorReporter)
Important: If there are CallParamContentNode children whose contents are not computable as JS expressions, then this function assumes that, elsewhere, code has been generated to define their respective 'param<n>' temporary variables.
Here are five example calls:
{call some.func data="all" /}
{call some.func data="$boo.foo" /}
{call some.func}
{param goo = $moo /}
{/call}
{call some.func data="$boo"}
{param goo}Blah{/param}
{/call}
{call some.func}
{param goo}
{for $i in range(3)}{$i}{/for}
{/param}
{/call}
Their respective objects to pass might be the following:
opt_data
opt_data.boo.foo
{goo: opt_data.moo}
soy.$$assignDefaults({goo: 'Blah'}, opt_data.boo)
{goo: param65}
Note that in the last case, the param content is not computable as JS expressions, so we assume
that code has been generated to define the temporary variable 'param<n>'.callNode - The call to generate code for.localVarTranslations - The current stack of replacement JS expressions for the local
variables (and foreach-loop special functions) current in scope.templateAliases - A mapping of fully qualified calls to a variable in scope.protected JsExpr maybeWrapContent(CallParamContentNode node, JsExpr valueJsExpr)
The expression for the constructor of SanitizedContent of the appropriate kind (e.g., "new SanitizedHtml"), or null if the node has no 'kind' attribute. This uses the variant used in internal blocks.