fix: use raw string to prevent quote issues
This commit is contained in:
parent
f6077d4a1d
commit
a1b480fc47
1 changed files with 39 additions and 42 deletions
7
index.ts
7
index.ts
|
|
@ -56,11 +56,9 @@ out += "|env: &mut minijinja::Environment| {\n";
|
||||||
|
|
||||||
for (const res of result.outputs) {
|
for (const res of result.outputs) {
|
||||||
// Can be consumed as blobs
|
// Can be consumed as blobs
|
||||||
let asset_text = await res.text();
|
const asset_text = await res.text();
|
||||||
asset_text = asset_text.replaceAll(/\n/g, "\\n");
|
|
||||||
asset_text = asset_text.replaceAll(/"/g, `\\"`);
|
|
||||||
const asset_path = path.normalize(res.path);
|
const asset_path = path.normalize(res.path);
|
||||||
out += `env.add_template("${asset_path}", "${asset_text}").expect("Embedded an invalid template");\n`;
|
out += `env.add_template("${asset_path}", r##"${asset_text}"##).expect("Embedded an invalid template");\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
out += "}";
|
out += "}";
|
||||||
|
|
@ -71,4 +69,3 @@ Bun.write(
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("Assets compiled!");
|
console.log("Assets compiled!");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue