Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 15x 15x 15x 17x 17x 6x 1x 5x 11x 15x 25x 36x 25x 15x | import { create } from 'xmlbuilder2';
import { XMLBuilder } from 'xmlbuilder2/lib/interfaces';
import { Verb } from './Verb';
/**
* @export
* @class NestableVerb
* @extends {Verb}
* Base class for all BXML verbs that can contain other verbs
*/
export class NestableVerb extends Verb {
name: string;
content: string;
attributes: object;
nestedVerbs?: Verb[];
/**
* Creates an instance of NestableVerb
* @param name [string] Name of the XML element
* @param content [string] Content of the XML element
* @param attributes [object] Attributes of the XML element
* @param nestedVerbs [Verb | Array<Verb>] Nested Verb or Array of Nested Verbs
*/
constructor(name: string, content?: string, attributes?: object, nestedVerbs?: Verb | Verb[]) {
super(name, content, attributes);
if (nestedVerbs) {
if (nestedVerbs instanceof Array) {
this.nestedVerbs = nestedVerbs;
} else {
this.nestedVerbs = [nestedVerbs];
}
} else {
this.nestedVerbs = [];
}
}
/**
* Generate an XML element for the verb
*/
generateXml(): XMLBuilder {
const xml = create().ele(this.name, this.attributes).txt(this.content);
this.nestedVerbs?.forEach((verb) => { xml.import(verb.generateXml()); });
return xml;
}
}
|