1
0

Renamed #inject to #use

This commit is contained in:
Zef Hemel
2022-08-10 09:18:11 +02:00
parent 6c7bb825a8
commit 47faea2289
4 changed files with 42 additions and 16 deletions
+8 -8
View File
@@ -195,21 +195,21 @@ functions:
insertInjectTemplate:
path: "./template.ts:insertTemplateText"
slashCommand:
name: inject
description: Inject template
name: use
description: Use a template
value: |
<!-- #inject [[|^|]] {} -->
<!-- #use [[|^|]] {} -->
<!-- /inject -->
<!-- /use -->
insertInjectCleanTemplate:
path: "./template.ts:insertTemplateText"
slashCommand:
name: inject-clean
description: Inject template clean
name: use-verbose
description: Use a template (verbose mode)
value: |
<!-- #inject-clean [[|^|]] {} -->
<!-- #use-verbose [[|^|]] {} -->
<!-- /inject-clean -->
<!-- /use-verbose -->
insertHRTemplate:
path: "./template.ts:insertTemplateText"
slashCommand:
+4 -4
View File
@@ -35,7 +35,7 @@ export async function updateMaterializedQueriesCommand() {
}
export const templateInstRegex =
/(<!--\s*#(inject|inject-clean|include)\s+\[\[([^\]]+)\]\](.*?)-->)(.+?)(<!--\s*\/\2\s*-->)/gs;
/(<!--\s*#(use|use-verbose|include)\s+\[\[([^\]]+)\]\](.*?)-->)(.+?)(<!--\s*\/\2\s*-->)/gs;
async function updateTemplateInstantiations(
text: string,
@@ -68,7 +68,7 @@ async function updateTemplateInstantiations(
}
let newBody = templateText;
// if it's a template injection (not a literal "include")
if (type == "inject" || type === "inject-clean") {
if (type === "use" || type === "use-verbose") {
let tree = await parseMarkdown(templateText);
extractMeta(tree, ["$disableDirectives"]);
templateText = renderToText(tree);
@@ -88,7 +88,7 @@ async function cleanTemplateInstantiations(text: string): Promise<string> {
text,
templateInstRegex,
async (fullMatch, startInst, type, template, args, body, endInst) => {
if (type === "inject-clean") {
if (type === "use") {
body = body.replaceAll(
queryRegex,
(
@@ -142,7 +142,7 @@ export async function updateMaterializedQueriesOnPage(
let parsedQuery = parseQuery(replaceTemplateVars(query, pageName));
console.log("Parsed query", parsedQuery);
// console.log("Parsed query", parsedQuery);
// Let's dispatch an event and see what happens
let results = await dispatch(
`query:${parsedQuery.table}`,