lib/html.js
function exportToHTML(targetDir, exportDiagram) {
    fs.ensureDirSync(targetDir);
    fs.ensureDirSync(targetDir + "/contents");
    fs.ensureDirSync(targetDir + "/diagrams");
    fs.copySync(__dirname + "/../resources/html/assets", targetDir + "/assets");
    // Generate html documents
    try {
        var root = mdjson.getRoot();
        mdjson.render(__dirname + "/../resources/html/templates/index.ejs", targetDir + "/index.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/navigation.ejs", targetDir + "/contents/navigation.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/diagrams.ejs", targetDir + "/contents/diagrams.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/element_index.ejs", targetDir + "/contents/element_index.html", root, { filters: filters });
        mdjson.renderBulk(__dirname + "/../resources/html/templates/content.ejs", targetDir + "/contents/<%=: element | toFilename %>.html", "@Model", { filters: filters }, function (err, file, elem) {
            if (err) {
                console.error(err);
            }
        });
    } catch (err) {
        console.error(err);
    }
    // Export diagram images
    if (exportDiagram) {
        var diagrams = mdjson.Repository.getInstancesOf("Diagram");
        _.each(diagrams, function (d) {
            mdjson.exportDiagramAsSVG(d, targetDir + "/diagrams/" + toFilename(d) + ".svg");
        });
    }
}
function exportToHTML(targetDir, exportDiagram) {
    fs.ensureDirSync(targetDir);
    fs.ensureDirSync(targetDir + "/contents");
    fs.ensureDirSync(targetDir + "/diagrams");
    fs.copySync(__dirname + "/../resources/html/assets", targetDir + "/assets");
    // Generate html documents
    try {
        var root = mdjson.getRoot();
        mdjson.render(__dirname + "/../resources/html/templates/index.ejs", targetDir + "/index.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/navigation.ejs", targetDir + "/contents/navigation.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/diagrams.ejs", targetDir + "/contents/diagrams.html", root, { filters: filters });
        mdjson.render(__dirname + "/../resources/html/templates/element_index.ejs", targetDir + "/contents/element_index.html", root, { filters: filters });
        mdjson.renderBulk(__dirname + "/../resources/html/templates/content.ejs", targetDir + "/contents/<%=: element | toFilename %>.html", "@Model", { filters: filters }, function (err, file, elem) {
            if (err) {
                console.error(err);
            }
        });
    } catch (err) {
        console.error(err);
    }
    // Export diagram images
    if (exportDiagram) {
        var diagrams = mdjson.Repository.getInstancesOf("Diagram");
        _.each(diagrams, function (d) {
            mdjson.exportDiagramAsSVG(d, targetDir + "/diagrams/" + toFilename(d) + ".svg");
        });
    }
}
function exportToHTML ( targetDir , exportDiagram ) { fs . ensureDirSync ( targetDir ) ; fs . ensureDirSync ( targetDir + "/contents" ) ; fs . ensureDirSync ( targetDir + "/diagrams" ) ; fs . copySync ( __dirname + "/../resources/html/assets" , targetDir + "/assets" ) ; // Generate html documents try { var root = mdjson . getRoot ( ) ; mdjson . render ( __dirname + "/../resources/html/templates/index.ejs" , targetDir + "/index.html" , root , { filters : filters } ) ; mdjson . render ( __dirname + "/../resources/html/templates/navigation.ejs" , targetDir + "/contents/navigation.html" , root , { filters : filters } ) ; mdjson . render ( __dirname + "/../resources/html/templates/diagrams.ejs" , targetDir + "/contents/diagrams.html" , root , { filters : filters } ) ; mdjson . render ( __dirname + "/../resources/html/templates/element_index.ejs" , targetDir + "/contents/element_index.html" , root , { filters : filters } ) ; mdjson . renderBulk ( __dirname + "/../resources/html/templates/content.ejs" , targetDir + "/contents/<%=: element | toFilename %>.html" , "@Model" , { filters : filters } , function ( err , file , elem ) { if ( err ) { console . error ( err ) ; } } ) ; } catch ( err ) { console . error ( err ) ; } // Export diagram images if ( exportDiagram ) { var diagrams = mdjson . Repository . getInstancesOf ( "Diagram" ) ; _ . each ( diagrams , function ( d ) { mdjson . exportDiagramAsSVG ( d , targetDir + "/diagrams/" + toFilename ( d ) + ".svg" ) ; } ) ; } }
Export to HTML
@param{string} targetDir Path where generated HTML files to be located
@param{boolean} exportDiagram Indicate whether generate diagram images or not
Export to HTML