if (node instanceof FuzzyXMLElement) {
FuzzyXMLElement element = (FuzzyXMLElement) node;
String tagName = element.getName();
if (WodHtmlUtils.isWOTag(tagName)) {
try {
WodParserCache cache = _caches.peek();
BuildProperties buildProperties = (BuildProperties)cache.getProject().getAdapter(BuildProperties.class);
IWodElement wodElement = WodHtmlUtils.getWodElement(element, buildProperties, true, cache);
if (wodElement == null) {
return true;
}
String elementTypeName = wodElement.getElementType();
TagDelegate tagDelegate = _tagDelegates.get(elementTypeName);
if (tagDelegate != null) {
tagDelegate.renderNode(wodElement, element, renderContext, xmlBuffer, _cssBuffer, _caches, _nodes);
}
else {
IType type = BindingReflectionUtils.findElementType(cache.getJavaProject(), elementTypeName, false, WodParserCache.getTypeCache());
LocalizedComponentsLocateResult componentsLocateResults = LocatePlugin.getDefault().getLocalizedComponentsLocateResult(type.getJavaProject().getProject(), wodElement.getElementType());
IFile htmlFile = componentsLocateResults.getFirstHtmlFile();
if (htmlFile != null) {
WodParserCache nestedCache = WodParserCache.parser(htmlFile);
if (nestedCache != null) {
Wo apiModel = ApiUtils.findApiModelWo(type, WodParserCache.getTypeCache().getApiCache(cache.getJavaProject()));
if (apiModel != null) {
String preview = apiModel.getPreview();
if (preview != null) {
StringBuffer previewBuffer = new StringBuffer();
Pattern bindingPattern = Pattern.compile("\\$([a-zA-Z0-9_]+)");
Matcher matcher = bindingPattern.matcher(preview);
while (matcher.find()) {
String bindingName = matcher.group(1);
IWodBinding binding = wodElement.getBindingNamed(bindingName);
if (binding == null) {
matcher.appendReplacement(previewBuffer, "");
} else {
matcher.appendReplacement(previewBuffer, binding.getValue());
}
}
matcher.appendTail(previewBuffer);
nestedCache = nestedCache.cloneCache();
nestedCache.getHtmlEntry().setContents("<span>" + previewBuffer.toString() + "</span>");
}
}
_caches.push(nestedCache);
_nodes.push(node);
try {
FuzzyXMLDocument nestedDocument = nestedCache.getHtmlEntry().getModel();
if (nestedDocument != null) {
nestedDocument.getDocumentElement().toXMLString(renderContext, xmlBuffer);
}
} finally {
_nodes.pop();