public final class GenIncrementalDomCodeVisitor extends GenJsCodeVisitor
GenJsCodeVisitor, adding logic to print the
function calls and changing how statements are combined.errorReporter, genCallCodeUtils, genJsExprsVisitor, isComputableAsJsExprsVisitor, jsExprTranslator, jsSrcOptions, localVarTranslations, templateAliases, templateRegistry| Modifier and Type | Method and Description |
|---|---|
protected void |
addCodeToRequireGeneralDeps(SoyFileNode soyFile)
Helper for visitSoyFileNode(SoyFileNode) to add code to require general dependencies.
|
protected CodeBuilder<JsExpr> |
createCodeBuilder() |
protected void |
generateFunctionBody(TemplateNode node)
Generates the function body.
|
protected String |
getGoogModuleNamespace(String soyNamespace)
Changes module namespaces, adding an extension of '.incrementaldom' to allow it to co-exist
with templates generated by jssrc.
|
protected IncrementalDomCodeBuilder |
getJsCodeBuilder() |
protected String |
getJsTypeName(SoyType type)
Returns the name of the JS type used to represent the given SoyType at runtime.
|
protected String |
getTemplateReturnType(TemplateNode node) |
protected void |
visitCallNode(CallNode node)
Example:
|
protected void |
visitCallParamContentNode(CallParamContentNode node) |
protected void |
visitChildren(SoyNode.ParentSoyNode<?> node)
Visits the children of a ParentSoyNode.
|
protected void |
visitHtmlAttributeNode(HtmlAttributeNode node)
Visits the
HtmlAttributeNode, this only occurs when we have something like: |
protected void |
visitHtmlCloseTagNode(HtmlCloseTagNode node)
Visits an
HtmlCloseTagNode, which occurs when an HTML tag is closed. |
protected void |
visitHtmlOpenTagEndNode(HtmlOpenTagEndNode node)
Visits an
HtmlOpenTagEndNode, which occurs at the end of an open tag containing
children that are not HtmlAttributeNodes. |
protected void |
visitHtmlOpenTagNode(HtmlOpenTagNode node)
Visits an
HtmlOpenTagNode, which occurs when an HTML tag is opened with no conditional
attributes. |
protected void |
visitHtmlOpenTagStartNode(HtmlOpenTagStartNode node)
Visits an
HtmlOpenTagStartNode, which occurs at the end of an open tag containing
children that are not HtmlAttributeNodes. |
protected void |
visitHtmlVoidTagNode(HtmlVoidTagNode node)
Visits an
HtmlVoidTagNode, which is equivalent to an HtmlOpenTagNode followed
immediately by an HtmlCloseTagNode
Example: |
protected void |
visitIfNode(IfNode node)
Generates calls in HTML/Attributes content as non-JsExprs, since Incremental DOM instructions
are needed and not a JavaScript expression.
|
protected void |
visitLetContentNode(LetContentNode node)
Generates the content of a
let statement. |
protected void |
visitMsgFallbackGroupNode(MsgFallbackGroupNode node) |
protected void |
visitMsgHtmlTagNode(MsgHtmlTagNode node) |
protected void |
visitPrintNode(PrintNode node)
Visit an
PrintNode, with special cases for a variable being printed within an attribute
declaration or as HTML content. |
protected void |
visitRawTextNode(RawTextNode node)
Visits a
RawTextNode, which occurs either as a child of any BlockNode or the 'child'
of an HTML tag. |
protected void |
visitTemplateNode(TemplateNode node)
Outputs a
TemplateNode, generating the function open and close, along with a a debug
template name. |
addCodeToRequireGoogModuleDeps, addGoogRequire, exec, gen, generateNonExpressionIfNode, genParamTypeChecks, getAssistantForMsgs, visitDebuggerNode, visitForeachNode, visitForeachNonemptyNode, visitForNode, visitForUseByAssistants, visitLetValueNode, visitLogNode, visitSoyFileNode, visitSoyFileSetNode, visitSoyNode, visitSwitchNodevisitvisitCallBasicNode, visitCallDelegateNode, visitCallParamNode, visitCallParamValueNode, visitChildrenAllowingConcurrentModification, visitCssNode, visitForeachIfemptyNode, visitIfCondNode, visitIfElseNode, visitLetNode, visitLoopNode, visitMsgNode, visitMsgPlaceholderNode, visitMsgPluralCaseNode, visitMsgPluralDefaultNode, visitMsgPluralNode, visitMsgSelectCaseNode, visitMsgSelectDefaultNode, visitMsgSelectNode, visitMsgSubstUnitNode, visitPrintDirectiveNode, visitSwitchCaseNode, visitSwitchDefaultNode, visitTemplateBasicNode, visitTemplateDelegateNode, visitXidNodevisitChildren, visitChildrenAllowingConcurrentModificationprotected CodeBuilder<JsExpr> createCodeBuilder()
createCodeBuilder in class GenJsCodeVisitorprotected IncrementalDomCodeBuilder getJsCodeBuilder()
getJsCodeBuilder in class GenJsCodeVisitorprotected String getGoogModuleNamespace(String soyNamespace)
getGoogModuleNamespace in class GenJsCodeVisitorsoyNamespace - The namespace as declared by the user.protected void addCodeToRequireGeneralDeps(SoyFileNode soyFile)
GenJsCodeVisitoraddCodeToRequireGeneralDeps in class GenJsCodeVisitorsoyFile - The node we're visiting.protected String getJsTypeName(SoyType type)
GenJsCodeVisitorgetJsTypeName in class GenJsCodeVisitorprotected String getTemplateReturnType(TemplateNode node)
getTemplateReturnType in class GenJsCodeVisitornode - The template node that is being generatedprotected void visitTemplateNode(TemplateNode node)
GenJsCodeVisitorTemplateNode, generating the function open and close, along with a a debug
template name.
If aliasing is not performed (which is always the case for V1 templates), this looks like:
my.namespace.func = function(opt_data, opt_sb) {
...
};
if (goog.DEBUG) {
my.namespace.func.soyTemplateName = 'my.namespace.func';
}
If aliasing is performed, this looks like:
function $func(opt_data, opt_sb) {
...
}
exports.func = $func;
if (goog.DEBUG) {
$func.soyTemplateName = 'my.namespace.func';
}
Note that the alias is not exactly the function name as in may conflict with a reserved
JavaScript identifier.
visitTemplateNode in class GenJsCodeVisitorprotected void generateFunctionBody(TemplateNode node)
GenJsCodeVisitorgenerateFunctionBody in class GenJsCodeVisitorprotected void visitChildren(SoyNode.ParentSoyNode<?> node)
GenJsCodeVisitor does.visitChildren in class GenJsCodeVisitornode - The parent node whose children to visit.AbstractSoyNodeVisitor.visitChildrenAllowingConcurrentModification(com.google.template.soy.soytree.SoyNode.ParentSoyNode<?>)protected void visitLetContentNode(LetContentNode node)
let statement. For HTML and attribute let statements, the
generated instructions inside the node are wrapped in a function which will be optionally
passed to another template and invoked in the correct location. All other kinds of let/param
statements are generated as a simple variable.visitLetContentNode in class GenJsCodeVisitorprotected void visitCallParamContentNode(CallParamContentNode node)
visitCallParamContentNode in class GenJsCodeVisitorprotected void visitCallNode(CallNode node)
GenJsCodeVisitor
{call some.func data="all" /}
{call some.func data="$boo.foo" /}
{call some.func}
{param goo: 88 /}
{/call}
{call some.func data="$boo"}
{param goo}
Hello {$name}
{/param}
{/call}
might generate
output += some.func(opt_data);
output += some.func(opt_data.boo.foo);
output += some.func({goo: 88});
output += some.func(soy.$$assignDefaults({goo: 'Hello ' + opt_data.name}, opt_data.boo);
visitCallNode in class GenJsCodeVisitorprotected void visitIfNode(IfNode node)
visitIfNode in class GenJsCodeVisitorprotected void visitHtmlAttributeNode(HtmlAttributeNode node)
HtmlAttributeNode, this only occurs when we have something like:
<div {if $condition}attr="value"{/if}>
or in a let/param of kind attributes, e.g.
{let $attrs kind="attributes"}
attr="value"
{/let}
If no attributes are conditional, then the HtmlAttributeNode will be a child of the
corresponding HtmlOpenTagNode/HtmlVoidTagNode and will not be visited directly.
Note that the value itself could still be conditional in that case.
<div disabled="{if $disabled}true{else}false{/if}">
This method prints the attribute declaration calls. For example, it would print the call to
iattr from the first example, resulting in:
if (condition) {
iattr(attr, "value");
}
visitHtmlAttributeNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitHtmlOpenTagNode(HtmlOpenTagNode node)
HtmlOpenTagNode, which occurs when an HTML tag is opened with no conditional
attributes. For example:
<div attr="value" attr2="{$someVar}">...</div>
generates
ie_open('div', null,
'attr', 'value',
'attr2', someVar);
visitHtmlOpenTagNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitHtmlCloseTagNode(HtmlCloseTagNode node)
HtmlCloseTagNode, which occurs when an HTML tag is closed. For example:
</div>generates
ie_close('div');
visitHtmlCloseTagNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitHtmlOpenTagStartNode(HtmlOpenTagStartNode node)
HtmlOpenTagStartNode, which occurs at the end of an open tag containing
children that are not HtmlAttributeNodes. For example,
<div {$attrs} attr="value">
The opening bracket and tag translate to
ie_open_start('div');
visitHtmlOpenTagStartNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitHtmlOpenTagEndNode(HtmlOpenTagEndNode node)
HtmlOpenTagEndNode, which occurs at the end of an open tag containing
children that are not HtmlAttributeNodes. For example,
<div {$attrs} attr="value">
The closing bracket translates to
ie_open_end();
visitHtmlOpenTagEndNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitHtmlVoidTagNode(HtmlVoidTagNode node)
HtmlVoidTagNode, which is equivalent to an HtmlOpenTagNode followed
immediately by an HtmlCloseTagNode
Example:
<div attr="value" attr2="{$someVar}"></div>
generates
ie_void('div', null,
'attr', 'value',
'attr2', someVar);
visitHtmlVoidTagNode in class AbstractHtmlSoyNodeVisitor<List<String>>protected void visitRawTextNode(RawTextNode node)
RawTextNode, which occurs either as a child of any BlockNode or the 'child'
of an HTML tag. Note that in the soy tree, tags and their logical HTML children do not have a
parent-child relationship, but are rather siblings. For example:
<div>Hello world</div>The text "Hello world" translates to
itext('Hello world');
visitRawTextNode in class AbstractSoyNodeVisitor<List<String>>protected void visitPrintNode(PrintNode node)
PrintNode, with special cases for a variable being printed within an attribute
declaration or as HTML content.
For attributes, if the variable is of kind attributes, it is invoked. Any other kind of variable is an error.
For HTML, if the variable is of kind HTML, it is invoked. Any other kind of variable gets
wrapped in a call to itext, resulting in a Text node.
visitPrintNode in class GenJsCodeVisitorprotected void visitMsgFallbackGroupNode(MsgFallbackGroupNode node)
visitMsgFallbackGroupNode in class GenJsCodeVisitorprotected void visitMsgHtmlTagNode(MsgHtmlTagNode node)
visitMsgHtmlTagNode in class GenJsCodeVisitor