use of com.google.template.soy.soytree.HtmlCommentNode in project closure-templates by google.
the class AddHtmlCommentsForDebugPass method createSoyDebug.
/**
* Generates an AST fragment that looks like:
*
* <p>{@code {if debugSoyTemplateInfo()}<!--dta_of...-->{/if}}
*
* @param insertionLocation The location where it is being inserted
* @param nodeIdGen The id generator to use
* @param htmlComment The content of the HTML comment
*/
private IfNode createSoyDebug(SourceLocation insertionLocation, IdGenerator nodeIdGen, String htmlComment) {
IfNode ifNode = new IfNode(nodeIdGen.genId(), insertionLocation);
FunctionNode funcNode = new FunctionNode(DebugSoyTemplateInfoFunction.INSTANCE, insertionLocation);
funcNode.setType(BoolType.getInstance());
IfCondNode ifCondNode = new IfCondNode(nodeIdGen.genId(), insertionLocation, "if", funcNode);
HtmlCommentNode htmlCommentNode = new HtmlCommentNode(nodeIdGen.genId(), insertionLocation);
// We need to escape the input HTML comments, in cases the file location contains "-->".
htmlCommentNode.addChild(new RawTextNode(nodeIdGen.genId(), htmlEscaper().escape(htmlComment), insertionLocation));
ifCondNode.addChild(htmlCommentNode);
ifNode.addChild(ifCondNode);
return ifNode;
}
Aggregations