Skip to content

Commit

Permalink
Remove %example-css-src% when no path to CSS (#988)
Browse files Browse the repository at this point in the history
* Remove "%example-css-src%" when no path to CSS

* Change to ternary

* Change to ternary in addCSS
  • Loading branch information
NiedziolkaMichal authored Nov 24, 2022
1 parent 2bb4423 commit 4abcd2a
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions lib/tabbedPageBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
: ""
);
}

/**
Expand All @@ -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;
}
Expand Down

0 comments on commit 4abcd2a

Please sign in to comment.