| 586 | } |
| 587 | |
| 588 | export class MultiTemplateParser implements XmlStateConsumer { |
| 589 | private _childParsers = new Array<TemplateParser>(); |
| 590 | private _value: KeyedTemplate[]; |
| 591 | |
| 592 | get value(): KeyedTemplate[] { |
| 593 | return this._value; |
| 594 | } |
| 595 | |
| 596 | constructor( |
| 597 | private parent: XmlStateConsumer, |
| 598 | private templateProperty: TemplateProperty, |
| 599 | ) {} |
| 600 | |
| 601 | public parse(args: xml.ParserEvent): XmlStateConsumer { |
| 602 | if (args.eventType === xml.ParserEventType.StartElement && args.elementName === 'template') { |
| 603 | const childParser = new TemplateParser(this, this.templateProperty, false); |
| 604 | childParser['key'] = args.attributes['key']; |
| 605 | this._childParsers.push(childParser); |
| 606 | |
| 607 | return childParser; |
| 608 | } |
| 609 | |
| 610 | if (args.eventType === xml.ParserEventType.EndElement) { |
| 611 | const name = ComponentParser.getComplexPropertyName(args.elementName); |
| 612 | if (name === this.templateProperty.name) { |
| 613 | const templates = new Array<KeyedTemplate>(); |
| 614 | for (let i = 0; i < this._childParsers.length; i++) { |
| 615 | templates.push({ |
| 616 | key: this._childParsers[i]['key'], |
| 617 | createView: this._childParsers[i].buildTemplate(), |
| 618 | }); |
| 619 | } |
| 620 | this._value = templates; |
| 621 | |
| 622 | return this.parent.parse(args); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | return this; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | export namespace TemplateParser { |
| 631 | export const enum State { |
nothing calls this directly
no outgoing calls
no test coverage detected