FIX: Nested templates are not parsed

This commit is contained in:
vakrilov
2015-08-07 11:44:16 +03:00
parent 171017e526
commit bccd5133a3
4 changed files with 63 additions and 7 deletions

View File

@ -5,10 +5,12 @@ var KNOWNTEMPLATES = "knownTemplates";
export class TemplateBuilder {
private _items: Array<string>;
private _templateProperty: definition.TemplateProperty;
private _nestingLevel: number;
constructor(templateProperty: definition.TemplateProperty) {
this._items = new Array<string>();
this._templateProperty = templateProperty;
this._nestingLevel = 0;
}
public get elementName(): string {
@ -16,15 +18,23 @@ export class TemplateBuilder {
}
public addStartElement(prefix: string, namespace: string, elementName: string, attributes: Object) {
this._nestingLevel++;
this._items.push("<" +
getElementNameWithPrefix(prefix, elementName) +
(namespace ? " " + getNamespace(prefix, namespace) : "") +
(attributes ? " " + getAttributesAsString(attributes) : "") +
getElementNameWithPrefix(prefix, elementName) +
(namespace ? " " + getNamespace(prefix, namespace) : "") +
(attributes ? " " + getAttributesAsString(attributes) : "") +
">");
}
public addEndElement(prefix: string, elementName: string) {
this._items.push("</" + getElementNameWithPrefix(prefix, elementName) + ">");
this._nestingLevel--;
if (!this.hasFinished()) {
this._items.push("</" + getElementNameWithPrefix(prefix, elementName) + ">");
}
}
public hasFinished() {
return this._nestingLevel < 0;
}
public build() {