Add prefixLines and substring helpers to query templates
This commit is contained in:
parent
928ef59190
commit
363a11a264
@ -144,6 +144,17 @@ export async function renderQuery(
|
|||||||
if (parsedQuery.render) {
|
if (parsedQuery.render) {
|
||||||
Handlebars.registerHelper("json", (v) => JSON.stringify(v));
|
Handlebars.registerHelper("json", (v) => JSON.stringify(v));
|
||||||
Handlebars.registerHelper("niceDate", (ts) => niceDate(new Date(ts)));
|
Handlebars.registerHelper("niceDate", (ts) => niceDate(new Date(ts)));
|
||||||
|
Handlebars.registerHelper("prefixLines", (v: string, prefix) =>
|
||||||
|
v
|
||||||
|
.split("\n")
|
||||||
|
.map((l) => prefix + l)
|
||||||
|
.join("\n")
|
||||||
|
);
|
||||||
|
|
||||||
|
Handlebars.registerHelper("substring", (s, from, to, elipsis = "") =>
|
||||||
|
s.length > to - from ? s.substring(from, to) + elipsis : s
|
||||||
|
);
|
||||||
|
|
||||||
Handlebars.registerHelper("yaml", (v, prefix) => {
|
Handlebars.registerHelper("yaml", (v, prefix) => {
|
||||||
if (typeof prefix === "string") {
|
if (typeof prefix === "string") {
|
||||||
let yaml = YAML.stringify(v)
|
let yaml = YAML.stringify(v)
|
||||||
|
Loading…
Reference in New Issue
Block a user