diff --git a/lib/tabbedPageBuilder.js b/lib/tabbedPageBuilder.js index a7948cc9e..2b17481d1 100644 --- a/lib/tabbedPageBuilder.js +++ b/lib/tabbedPageBuilder.js @@ -9,16 +9,12 @@ import * as processor from "./processor.js"; * @returns the processed template string */ function addCSS(currentPage, tmpl) { - if (currentPage.cssExampleSrc) { - tmpl = tmpl.replace( - "%example-css-src%", - fse.readFileSync(currentPage.cssExampleSrc, "utf8") - ); - } else { - tmpl.replace("%example-css-src%", ""); - } - - return tmpl; + return tmpl.replace( + "%example-css-src%", + currentPage.cssExampleSrc + ? fse.readFileSync(currentPage.cssExampleSrc, "utf8") + : "" + ); } /** @@ -40,14 +36,12 @@ function addHTML(currentPage, tmpl) { * @returns the processed template string */ function addJS(currentPage, tmpl) { - if (currentPage.jsExampleSrc) { - tmpl = tmpl.replace( - "%example-js-src%", - fse.readFileSync(currentPage.jsExampleSrc, "utf8") - ); - } else { - tmpl = tmpl.replace("%example-js-src%", ""); - } + tmpl = tmpl.replace( + "%example-js-src%", + currentPage.jsExampleSrc + ? fse.readFileSync(currentPage.jsExampleSrc, "utf8") + : "" + ); return tmpl; }