templateFormatter: add cases() template function; Tags: add set/get tag functions to store/retrieve variables within tags

This commit is contained in:
Dragory 2019-03-16 17:54:05 +02:00
parent a8d274c054
commit 96b2d33423
2 changed files with 14 additions and 0 deletions

View file

@ -196,9 +196,17 @@ export class TagsPlugin extends ZeppelinPlugin<ITagsPluginConfig, ITagsPluginPer
// Format the string
try {
const dynamicVars = {};
body = await renderTemplate(body, {
args: tagArgs,
...this.tagFunctions,
set(name, val) {
if (typeof name !== "string") return;
dynamicVars[name] = val;
},
get(name) {
return dynamicVars[name] == null ? "" : dynamicVars[name];
},
});
} catch (e) {
if (e instanceof TemplateParseError) {