Work on #587: revamped templates

This commit is contained in:
Zef Hemel
2023-12-21 18:38:02 +01:00
parent c38e6cfc25
commit 70ef6ed9da
42 changed files with 664 additions and 486 deletions
-35
View File
@@ -64,41 +64,6 @@ export async function queryComplete(completeEvent: CompleteEvent) {
return null;
}
export async function templateVariableComplete(completeEvent: CompleteEvent) {
const match = /\{\{([\w@]*)$/.exec(completeEvent.linePrefix);
if (!match) {
return null;
}
const handlebarOptions = buildHandebarOptions({ name: "" } as PageMeta);
let allCompletions: any[] = Object.keys(handlebarOptions.helpers).map(
(name) => ({ label: name, detail: "helper" }),
);
allCompletions = allCompletions.concat(
Object.keys(handlebarOptions.data).map((key) => ({
label: `@${key}`,
detail: "global variable",
})),
);
const completions = (await events.dispatchEvent(
`attribute:complete:_`,
{
source: "",
prefix: match[1],
} as AttributeCompleteEvent,
)).flat() as AttributeCompletion[];
allCompletions = allCompletions.concat(
attributeCompletionsToCMCompletion(completions),
);
return {
from: completeEvent.pos - match[1].length,
options: allCompletions,
};
}
export function attributeCompletionsToCMCompletion(
completions: AttributeCompletion[],
) {
-5
View File
@@ -23,11 +23,6 @@ functions:
path: ./complete.ts:queryComplete
events:
- editor:complete
handlebarHelperComplete:
path: ./complete.ts:templateVariableComplete
events:
- editor:complete
# Conversion
convertToLiveQuery:
path: command.ts:convertToLive