docx
    Preparing search index...

    Class IgnoreIfEmptyXmlComponentAbstract

    XML component that is excluded from output if it has no meaningful content.

    IgnoreIfEmptyXmlComponent is useful for optional container elements that should only appear in the XML if they contain children or attributes. If the element would be empty, it returns undefined instead, causing it to be excluded from the output.

    class OptionalContainer extends IgnoreIfEmptyXmlComponent {
    constructor(items?: Item[]) {
    super("w:container");
    if (items) {
    items.forEach(item => this.root.push(item));
    }
    }
    }

    const container1 = new OptionalContainer([item1, item2]);
    // Renders: <w:container>...</w:container>

    const container2 = new OptionalContainer();
    // Renders: nothing (excluded from output)

    Hierarchy (View Summary)

    Index

    Constructors

    Methods