38 lines
805 B
TypeScript
38 lines
805 B
TypeScript
|
import Toml from "@ltd/j-toml";
|
||
|
|
||
|
/** @jsx h */
|
||
|
const h = require('vhtml')
|
||
|
|
||
|
function Template(props: any) {
|
||
|
return <div><p>{props.data.name}</p></div>;
|
||
|
}
|
||
|
|
||
|
function statSheetTemplate(lines) {
|
||
|
const data = Toml.parse(lines.join("\n"), { bigint: false });
|
||
|
return <Template data={data} />;
|
||
|
}
|
||
|
|
||
|
function StatSheetBlock() {
|
||
|
this.named("stat-sheet");
|
||
|
this.onContexts("open", "example");
|
||
|
this.process((parent, reader, attrs) => {
|
||
|
const lines = reader.getLines();
|
||
|
const newHtml = statSheetTemplate(lines);
|
||
|
return this.createBlock(parent, "pass", newHtml, attrs);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function register(registry) {
|
||
|
if (registry.register) {
|
||
|
registry.register(function () {
|
||
|
this.block(StatSheetBlock);
|
||
|
});
|
||
|
} else {
|
||
|
registry.block(StatSheetBlock);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default {
|
||
|
register
|
||
|
}
|