Skip to content

Commit 143c34f

Browse files
committed
added helpers for custom templates
1 parent 7b71ba5 commit 143c34f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/core/template.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export class Template {
7070
Handlebars.registerHelper('parseJSON', parseJSON);
7171
Handlebars.registerHelper('startsWith', startsWith);
7272
Handlebars.registerHelper('substring', substring);
73+
Handlebars.registerHelper('urlEncode', urlEncode);
74+
Handlebars.registerHelper('toJSON', toJSON);
7375
}
7476

7577
public static getInstance(): Template {
@@ -177,3 +179,11 @@ const link = (source: StringOrLink): string => {
177179
return `[${source.title}](${source.url})`;
178180
}
179181
};
182+
183+
const urlEncode = (heading: string): string => {
184+
return `${encodeURI(heading)}`;
185+
};
186+
187+
const toJSON = (obj: object): string => {
188+
return JSON.stringify(obj);
189+
};

0 commit comments

Comments
 (0)