public class GenCallCodeUtils extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
GenCallCodeUtils(SoyJsSrcOptions options,
DelTemplateNamer delTemplateNamer,
IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor,
GenJsExprsVisitor.GenJsExprsVisitorFactory genJsExprsVisitorFactory) |
| Modifier and Type | Method and Description |
|---|---|
CodeChunk.WithValue |
gen(CallNode callNode,
TemplateAliases templateAliases,
TranslationContext translationContext,
ErrorReporter errorReporter)
Generates the JS expression for a given call.
|
protected CodeChunk.WithValue |
maybeWrapContent(CodeChunk.Generator generator,
CallParamContentNode node,
CodeChunk.WithValue content)
If the param node had a content kind specified, it was autoescaped in the
corresponding context.
|
protected GenCallCodeUtils(SoyJsSrcOptions options, DelTemplateNamer delTemplateNamer, IsComputableAsJsExprsVisitor isComputableAsJsExprsVisitor, GenJsExprsVisitor.GenJsExprsVisitorFactory genJsExprsVisitorFactory)
public CodeChunk.WithValue gen(CallNode callNode, TemplateAliases templateAliases, TranslationContext translationContext, 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.templateAliases - A mapping of fully qualified calls to a variable in scope.protected CodeChunk.WithValue maybeWrapContent(CodeChunk.Generator generator, CallParamContentNode node, CodeChunk.WithValue content)
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.