WIP: transforming through handlebars, parsing the html and resolving the imports

This commit is contained in:
2023-04-27 15:18:14 +02:00
parent da9dc3bdc1
commit 240d5cfe9a
8 changed files with 335 additions and 126 deletions

View File

@@ -115,7 +115,7 @@ test.serial('template', async (t) => {
input: 'batman.js',
plugins: [
html({
template: () => '<html><body><main></main></body></html>'
transform: () => '<html><body><main></main></body></html>'
})
]
});

View File

@@ -0,0 +1,4 @@
export const notSoIifi = ()=>{
return `I'm "annoying" ${"in case we need to test \`string\` escaping.''"}`;
}
console.log(notSoIifi());

View File

@@ -8,7 +8,7 @@ import { getCode } from "../util/test.js";
import html from "../../src/index.ts";
import handlebars from "handlebars";
const output = { dir: 'output', format: 'umd' };
const output = { dir: 'output', format: 'es' };
import {readFile} from "node:fs/promises";
import {fileURLToPath} from "node:url";
@@ -18,11 +18,11 @@ process.chdir(join(__dirname, 'fixtures'));
test.serial('handlebars', async (t) => {
const template = await readFile('index.hbs', {encoding: "utf-8"});
const bundle = await rollup({
input: 'batman.js',
input: 'index.hbs',
plugins: [
html({
fileName: 'index.html',
template(ctx){
// Should we define an output template here?!
transform(ctx){
return handlebars.compile(template)({a:'a'})
}
})