3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-13 21:35:02 +00:00

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

@ -342,6 +342,12 @@ const baseValues = {
return result / parseFloat(arg);
}, args[0]);
},
cases(mod, ...cases) {
if (cases.length === 0) return "";
if (isNaN(mod)) return "";
mod = parseInt(mod, 10) - 1;
return cases[Math.max(0, mod % cases.length)];
},
};
export async function renderTemplate(template: string, values = {}, includeBaseValues = true) {