packages/okam-build/lib/processor/template/serializer/index.js
function serializeDom(dom, opts) {
    if (!Array.isArray(dom)) {
        dom = [dom];
    }

    opts = opts || {};

    let output = '';
    for (let i = 0, len = dom.length; i < len; i++) {
        let elem = dom[i];
        if (elem.removed) { // ignore removed node
            continue;
        }

        if (elem.type === 'root') {
            output += serializeDom(elem.children, opts);
        }
        else if (ElementType.isTag(elem)) {
            output += serializeTag(elem, opts);
        }
        else if (elem.type === ElementType.Directive) {
            output += serializeDirective(elem);
        }
        else if (elem.type === ElementType.Comment) {
            output += serializeComment(elem);
        }
        else if (elem.type === ElementType.CDATA) {
            output += serializeCDATA(elem);
        }
        else {
            output += serializeText(elem, opts);
        }
    }

    return output;
}
function serializeDom(dom, opts) {
    if (!Array.isArray(dom)) {
        dom = [dom];
    }

    opts = opts || {};

    let output = '';
    for (let i = 0, len = dom.length; i < len; i++) {
        let elem = dom[i];
        if (elem.removed) { // ignore removed node
            continue;
        }

        if (elem.type === 'root') {
            output += serializeDom(elem.children, opts);
        }
        else if (ElementType.isTag(elem)) {
            output += serializeTag(elem, opts);
        }
        else if (elem.type === ElementType.Directive) {
            output += serializeDirective(elem);
        }
        else if (elem.type === ElementType.Comment) {
            output += serializeComment(elem);
        }
        else if (elem.type === ElementType.CDATA) {
            output += serializeCDATA(elem);
        }
        else {
            output += serializeText(elem, opts);
        }
    }

    return output;
}
Serialize dom

@param {Object|Array} dom the dom to serialize
@param {Object} opts the serialize options
@param {boolean=} opts.xmlMode whether serialize using xml mode, optional, by defaul false
@param {boolean=} opts.decodeEntities whether the given dom entities are decoded, optional, by default false
@return {string}