rename toXml -> prepForXml
This commit is contained in:
@ -5,5 +5,5 @@ export abstract class BaseXmlComponent {
|
|||||||
this.rootKey = rootKey;
|
this.rootKey = rootKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract toXml(): object;
|
public abstract prepForXml(): object;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public toXml(): object {
|
public prepForXml(): object {
|
||||||
const attrs = {};
|
const attrs = {};
|
||||||
if (this.root !== undefined) {
|
if (this.root !== undefined) {
|
||||||
_.forOwn(this.root, (value, key) => {
|
_.forOwn(this.root, (value, key) => {
|
||||||
@ -26,8 +26,6 @@ export abstract class XmlAttributeComponent extends BaseXmlComponent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const ret = {};
|
return {[this.rootKey]: attrs};
|
||||||
ret[this.rootKey] = attrs;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,15 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
|||||||
this.root = new Array<BaseXmlComponent>();
|
this.root = new Array<BaseXmlComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public toXml(): object {
|
public prepForXml(): object {
|
||||||
// What does 'ret' stand for? Retain? Return?
|
const children = this.root.map((comp) => {
|
||||||
const ret = this.root.map((comp) => {
|
|
||||||
if (comp instanceof BaseXmlComponent) {
|
if (comp instanceof BaseXmlComponent) {
|
||||||
return comp.toXml();
|
return comp.prepForXml();
|
||||||
}
|
}
|
||||||
return comp;
|
return comp;
|
||||||
}).filter((comp) => comp); // Exclude null, undefined, and empty strings
|
}).filter((comp) => comp); // Exclude null, undefined, and empty strings
|
||||||
return {
|
return {
|
||||||
[this.rootKey]: ret,
|
[this.rootKey]: children,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,6 @@ import { BaseXmlComponent } from "../docx/xml-components";
|
|||||||
|
|
||||||
export class Formatter {
|
export class Formatter {
|
||||||
public format(input: BaseXmlComponent): any {
|
public format(input: BaseXmlComponent): any {
|
||||||
return input.toXml();
|
return input.prepForXml();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user