mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
FIX: Nested templates are not parsed
This commit is contained in:
@ -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() {
|
||||
|
Reference in New Issue
Block a user