Skip to content

Commit

Permalink
Add SCRIPT to PREHTML.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Aug 5, 2024
1 parent 723b453 commit a3ca5fb
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions _includes/vhv-scripts/html/displayPrePostHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,25 @@ function displayPrePostHtml() {
if (PREHTML && Array.isArray(PREHTML)) {
let pretext = "";
for (let i=0; i<PREHTML.length; i++) {
if (Object.keys(PREHTML[i]).length !== 0) {
let text = null;
if (language) {
text = PREHTML[i][`CONTENT-${language}`];
}
if (typeof text === "undefined") {
text = PREHTML[i].CONTENT;
if (Object.keys(PREHTML[i]).length == 0) {
continue;
}
if (PREHTML[i].SCRIPT) {
// Currently only one script is allowed at a time.
let jelement = document.querySelector("script#script-prehtml");
if (jelement) {
jelement.textContent = PREHTML[i].SCRIPT;
}
text = applyParameters(text, PREHTML[i], REFS, language);
pretext += text;
}
let text = null;
if (language) {
text = PREHTML[i][`CONTENT-${language}`];
}
if (typeof text === "undefined") {
text = PREHTML[i].CONTENT;
}
text = applyParameters(text, PREHTML[i], REFS, language);
pretext += text;
}
if (prehtmlElement) {
if (pretext) {
Expand All @@ -81,23 +89,25 @@ function displayPrePostHtml() {
if (POSTHTML && Array.isArray(POSTHTML)) {
let posttext = "";
for (let i=0; i<POSTHTML.length; i++) {
if (Object.keys(POSTHTML[i]).length !== 0) {
if (POSTHTML[i].JAVASCRIPT) {
let jelement = document.querySelector("script#script-posthtml");
if (jelement) {
jelement.textContent = POSTHTML[i].JAVASCRIPT;
}
}
let text; // output text of PREHTML content
if (language) {
text = POSTHTML[i][`CONTENT-${language}`];
}
if (typeof text === "undefined") {
text = POSTHTML[i].CONTENT;
if (Object.keys(POSTHTML[i]).length == 0) {
continue;
}
if (POSTHTML[i].SCRIPT) {
// Currently only one script is allowed at a time.
let jelement = document.querySelector("script#script-posthtml");
if (jelement) {
jelement.textContent = POSTHTML[i].SCRIPT;
}
text = applyParameters(text, POSTHTML[i], REFS, language);
posttext += text;
}
let text; // output text of POSTHTML content
if (language) {
text = POSTHTML[i][`CONTENT-${language}`];
}
if (typeof text === "undefined") {
text = POSTHTML[i].CONTENT;
}
text = applyParameters(text, POSTHTML[i], REFS, language);
posttext += text;
}
if (posthtmlElement) {
if (posttext) {
Expand Down

0 comments on commit a3ca5fb

Please sign in to comment.