use of net.htmlparser.jericho.CharacterReference in project vue-gwt by Axellience.
the class TemplateParser method processElement.
/**
* Recursive method that will process the whole template DOM tree.
* @param element Current element being processed
*/
private void processElement(Element element) {
context.setCurrentSegment(element);
currentProp = null;
currentAttribute = null;
Attributes attributes = element.getAttributes();
Attribute vForAttribute = attributes != null ? attributes.get("v-for") : null;
if (vForAttribute != null) {
// Add a context layer for our v-for
context.addContextLayer();
// Process the v-for expression, and update our attribute
String processedVForValue = processVForValue(vForAttribute.getValue());
outputDocument.replace(vForAttribute.getValueSegment(), processedVForValue);
}
// Process the element
if (attributes != null)
processElementAttributes(element);
// Process text segments
StreamSupport.stream(((Iterable<Segment>) element::getNodeIterator).spliterator(), false).filter(segment -> !(segment instanceof Tag) && !(segment instanceof CharacterReference)).filter(segment -> {
for (Element child : element.getChildElements()) if (child.encloses(segment))
return false;
return true;
}).forEach(this::processTextNode);
// Recurse downwards
element.getChildElements().forEach(this::processElement);
// After downward recursion, pop the context layer
if (vForAttribute != null)
context.popContextLayer();
}
Aggregations