use of com.google.template.soy.soytree.HtmlCloseTagNode in project closure-templates by google.
the class HtmlRewritePass method run.
@Override
public void run(SoyFileNode file, IdGenerator nodeIdGen) {
new Visitor(nodeIdGen, file.getFilePath(), errorReporter).exec(file);
/*
* Validates that the only children of close tags can be {@code phname} attributes.
*
* <p>Later passes validate that phnames for close tags only appear in messages.
*/
for (HtmlCloseTagNode closeTag : SoyTreeUtils.getAllNodesOfType(file, HtmlCloseTagNode.class)) {
List<StandaloneNode> children = closeTag.getChildren();
HtmlAttributeNode phNameAttribute = closeTag.getDirectAttributeNamed(MessagePlaceholders.PHNAME_ATTR);
HtmlAttributeNode phExAttribute = closeTag.getDirectAttributeNamed(MessagePlaceholders.PHEX_ATTR);
// the child at index 0 is the tag name
for (int i = 1; i < children.size(); i++) {
StandaloneNode child = children.get(i);
if (child == phNameAttribute || child == phExAttribute) {
// the phname and phex attributes are validated later and allowed in close nodes
continue;
}
errorReporter.report(child.getSourceLocation(), UNEXPECTED_CLOSE_TAG_CONTENT);
}
}
}
Aggregations