You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
627 B
14 lines
627 B
export function ensureDefine(templateName: string, templateContent: string): string {
|
|
// notification template content must be wrapped in {{ define "name" }} tag,
|
|
// but this is not obvious because user also has to provide name separately in the form.
|
|
// so if user does not manually add {{ define }} tag, we do it automatically
|
|
let content = templateContent.trim();
|
|
if (!content.match(/\{\{\s*define/)) {
|
|
const indentedContent = content
|
|
.split('\n')
|
|
.map((line) => ' ' + line)
|
|
.join('\n');
|
|
content = `{{ define "${templateName}" }}\n${indentedContent}\n{{ end }}`;
|
|
}
|
|
return content;
|
|
}
|
|
|