Skip to content

Commit

Permalink
Fix broken handlebars templates due to XLST attribute escaping.
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindolf committed Jan 29, 2025
1 parent 718f712 commit 2517505
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions js/htmlview.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@ function parseStatus(parsePhase, errorCode) {
return "⬜";
}

function templateFix(str, data) {
// sadly libxslt translating the handlebar templates causes
// attribute escaping and thereby destroying template expressions
// in attributes, which we need to restore
return template(str
.replace(/"%7B%7B/g, "\"{{")
.replace(/%7D%7D"/g, "}}\"")
.replace(/%5B/g, "[")
.replace(/%5D/g, "]"),
data);
}

async function load_node(data, baseURL, direction) {
let node = JSON.parse(decodeURIComponent(data));

// FIXME
console.log(node);

prepare(baseURL, node.title);
render("body", template(document.getElementById('template').innerHTML), {
render("body", templateFix(document.getElementById('template').innerHTML), {
node,
direction,
publisher : metadata_get(node, "publisher"),
Expand Down Expand Up @@ -102,7 +114,7 @@ async function load_item(data, baseURL, direction) {
console.log(item);

prepare(baseURL, item.title);
render("body", template (document.getElementById('template').innerHTML), {
render("body", templateFix (document.getElementById('template').innerHTML), {
item,
direction,

Expand Down

0 comments on commit 2517505

Please sign in to comment.