public final class GenIncrementalDomCodeVisitor extends GenJsCodeVisitor
GenJsCodeVisitor, adding logic to print the
function calls and changing how statements are combined.errorReporter, genCallCodeUtils, genJsExprsVisitor, isComputableAsJsExprsVisitor, jsSrcOptions, templateAliases, templateRegistry, templateTranslationContext| Modifier and Type | Method and Description |
|---|---|
protected com.google.template.soy.incrementaldomsrc.IncrementalDomCodeBuilder |
createChildJsCodeBuilder() |
protected JsCodeBuilder |
createCodeBuilder() |
protected CodeChunk |
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 com.google.template.soy.incrementaldomsrc.IncrementalDomCodeBuilder |
getJsCodeBuilder() |
protected String |
getTemplateReturnType(TemplateNode node) |
protected void |
visit(SoyNode node)
Visits the given node to execute the function defined by this visitor.
|
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. |
protected void |
visitHtmlAttributeValueNode(HtmlAttributeValueNode node) |
protected void |
visitHtmlCloseTagNode(HtmlCloseTagNode node)
Visits an
HtmlCloseTagNode, which occurs when an HTML tag is closed. |
protected void |
visitHtmlOpenTagNode(HtmlOpenTagNode node)
Visits an
HtmlOpenTagNode, which occurs when an HTML tag is opened with no conditional
attributes. |
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. |
protected void |
visitVeLogNode(VeLogNode node) |
exec, gen, generateNonExpressionIfNode, genParamTypeChecks, getAssistantForMsgs, sanitize, visitChildrenReturningCodeChunk, visitDebuggerNode, visitForNode, visitForNonemptyNode, visitForUseByAssistants, visitForUseByAssistantsAsCodeChunk, visitLetValueNode, visitLogNode, visitSoyFileNode, visitSoyFileSetNode, visitSoyNode, visitSwitchNodevisitCallBasicNode, visitCallDelegateNode, visitCallParamNode, visitCallParamValueNode, visitChildrenAllowingConcurrentModification, visitForIfemptyNode, visitHtmlCommentNode, visitIfCondNode, visitIfElseNode, visitLetNode, visitMsgNode, visitMsgPlaceholderNode, visitMsgPluralCaseNode, visitMsgPluralDefaultNode, visitMsgPluralNode, visitMsgSelectCaseNode, visitMsgSelectDefaultNode, visitMsgSelectNode, visitMsgSubstUnitNode, visitPrintDirectiveNode, visitSwitchCaseNode, visitSwitchDefaultNode, visitTemplateBasicNode, visitTemplateDelegateNodevisitChildren, visitChildrenAllowingConcurrentModificationprotected JsCodeBuilder createCodeBuilder()
createCodeBuilder in class GenJsCodeVisitorprotected com.google.template.soy.incrementaldomsrc.IncrementalDomCodeBuilder createChildJsCodeBuilder()
createChildJsCodeBuilder in class GenJsCodeVisitorprotected com.google.template.soy.incrementaldomsrc.IncrementalDomCodeBuilder getJsCodeBuilder()
getJsCodeBuilder in class GenJsCodeVisitorprotected void visit(SoyNode node)
AbstractNodeVisitorvisit in class AbstractSoyNodeVisitor<List<String>>node - The node to visit.protected String getGoogModuleNamespace(String soyNamespace)
getGoogModuleNamespace in class GenJsCodeVisitorsoyNamespace - The namespace as declared by the user.protected 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 CodeChunk 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. The attribute nodes will typically be children of the
corresponding HtmlOpenTagNode or in a let/param of kind attributes, e.g.
{let $attrs kind="attributes"}
attr="value"
{/let}
This method prints the attribute declaration calls. For example, given
<div {if $condition}attr="value"{/if}>
it would print the call to incrementalDom.attr, resulting in:
if (condition) {
IncrementalDom.attr(attr, "value");
}
visitHtmlAttributeNode in class AbstractSoyNodeVisitor<List<String>>protected void visitHtmlAttributeValueNode(HtmlAttributeValueNode node)
visitHtmlAttributeValueNode in class AbstractSoyNodeVisitor<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
IncrementalDom.elementOpen('div');
IncrementalDom.attr('attr', 'value');
IncrementalDom.attr('attr2', someVar);
IncrementalDom.elementClose();
visitHtmlOpenTagNode in class AbstractSoyNodeVisitor<List<String>>protected void visitHtmlCloseTagNode(HtmlCloseTagNode node)
HtmlCloseTagNode, which occurs when an HTML tag is closed. For example:
</div>generates
incrementalDom.elementClose('div');
visitHtmlCloseTagNode in class AbstractSoyNodeVisitor<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
incrementalDom.text('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 incrementalDom.text, resulting in a Text node.
visitPrintNode in class GenJsCodeVisitorprotected void visitVeLogNode(VeLogNode node)
visitVeLogNode in class AbstractSoyNodeVisitor<List<String>>protected void visitMsgFallbackGroupNode(MsgFallbackGroupNode node)
visitMsgFallbackGroupNode in class GenJsCodeVisitorprotected void visitMsgHtmlTagNode(MsgHtmlTagNode node)
visitMsgHtmlTagNode in class GenJsCodeVisitor