Major directive refactor (#195)

Fixes #188 #144 #76: major refactor of directive parsing, rendering, styling
This commit is contained in:
Zef Hemel
2022-12-14 20:04:20 +01:00
committed by GitHub
parent 79e1151ee6
commit aaebea5e54
44 changed files with 656 additions and 347 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
// This is some shocking stuff. My profession would kill me for this.
import * as YAML from "yaml";
import { ParseTree } from "../../plug-api/lib/tree.ts";
import { jsonToMDTable, renderTemplate } from "./util.ts";
// Enables plugName.functionName(arg1, arg2) syntax in JS expressions
@@ -20,8 +21,11 @@ const expressionRegex = /(.+?)(\s+render\s+\[\[([^\]]+)\]\])?$/;
export async function evalDirectiveRenderer(
_directive: string,
_pageName: string,
expression: string,
expression: string | ParseTree,
): Promise<string> {
if (typeof expression !== "string") {
throw new Error("Expected a string");
}
console.log("Got JS expression", expression);
const match = expressionRegex.exec(expression);
if (!match) {