lib/util/page-generator.js
function normalizePage(content) {
    var data = {
        "head-start": [],
        "head": [],
        "head-end": [],
        body: []
    };

    if (typeof content === "string") {
        data.body.push(content);
    } else {
        ["head-start", "head", "head-end", "body"].forEach(function (section) {
            var sectionContent = content[section];
            if (!sectionContent) {
                return;
            }

            if (!_.isArray(sectionContent)) {
                data[section].push(sectionContent);
            } else {
                data[section] = sectionContent;
            }
        });
    }

    return data;
}
function normalizePage(content) {
    var data = {
        "head-start": [],
        "head": [],
        "head-end": [],
        body: []
    };

    if (typeof content === "string") {
        data.body.push(content);
    } else {
        ["head-start", "head", "head-end", "body"].forEach(function (section) {
            var sectionContent = content[section];
            if (!sectionContent) {
                return;
            }

            if (!_.isArray(sectionContent)) {
                data[section].push(sectionContent);
            } else {
                data[section] = sectionContent;
            }
        });
    }

    return data;
}
function normalizePage ( content ) { var data = { "head-start" : [ ] , "head" : [ ] , "head-end" : [ ] , body : [ ] } ; if ( typeof content === "string" ) { data . body . push ( content ) ; } else { [ "head-start" , "head" , "head-end" , "body" ] . forEach ( function ( section ) { var sectionContent = content [ section ] ; if ( ! sectionContent ) { return ; } if ( ! _ . isArray ( sectionContent ) ) { data [ section ] . push ( sectionContent ) ; } else { data [ section ] = sectionContent ; } } ) ; } return data ; }
Given any acceptable page description, generate an object with head and body as arrays.
Normalized pages can be merged easily
Given any acceptable page description generate an object with head and body as arrays . Normalized pages can be merged easily