Process handlebars in frontmatter for slash templates too
This commit is contained in:
parent
7fec3fe587
commit
b86d45880a
@ -31,6 +31,9 @@ export async function renderTemplate(
|
|||||||
} else {
|
} else {
|
||||||
frontmatterText = await YAML.stringify(frontmatter.frontmatter);
|
frontmatterText = await YAML.stringify(frontmatter.frontmatter);
|
||||||
}
|
}
|
||||||
|
frontmatterText = await handlebars.renderTemplate(frontmatterText, data, {
|
||||||
|
page: pageMeta,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
frontmatter: frontmatterText,
|
frontmatter: frontmatterText,
|
||||||
|
@ -35,7 +35,7 @@ export async function insertSlashTemplate(slashCompletion: SlashCompletion) {
|
|||||||
const templateText = await space.readPage(slashCompletion.templatePage);
|
const templateText = await space.readPage(slashCompletion.templatePage);
|
||||||
let { frontmatter, text } = await renderTemplate(templateText, pageObject);
|
let { frontmatter, text } = await renderTemplate(templateText, pageObject);
|
||||||
|
|
||||||
const cursorPos = await editor.getCursor();
|
let cursorPos = await editor.getCursor();
|
||||||
|
|
||||||
if (frontmatter) {
|
if (frontmatter) {
|
||||||
frontmatter = frontmatter.trim();
|
frontmatter = frontmatter.trim();
|
||||||
@ -49,6 +49,7 @@ export async function insertSlashTemplate(slashCompletion: SlashCompletion) {
|
|||||||
await editor.dispatch(dispatch);
|
await editor.dispatch(dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursorPos = await editor.getCursor();
|
||||||
const carretPos = text.indexOf("|^|");
|
const carretPos = text.indexOf("|^|");
|
||||||
text = text.replace("|^|", "");
|
text = text.replace("|^|", "");
|
||||||
await editor.insertAtCursor(text);
|
await editor.insertAtCursor(text);
|
||||||
|
Loading…
Reference in New Issue
Block a user