diff --git a/template.go b/template.go index d67d919..8458729 100644 --- a/template.go +++ b/template.go @@ -47,8 +47,7 @@ func templateEmail(content string, variables []string, conditionals []string, va } ifEnd = i - 1 if ifTrue { - b := templateEmail(content[ifStart:ifEnd+1], variables, conditionals, values) - out += b + out += templateEmail(content[ifStart:ifEnd+1], variables, conditionals, values) ifTrue = false } } else if c == '}' { diff --git a/ts/modules/settings.ts b/ts/modules/settings.ts index a1e2e2b..17aea72 100644 --- a/ts/modules/settings.ts +++ b/ts/modules/settings.ts @@ -859,26 +859,25 @@ class EmailEditor { } innerHTML = ''; - for (let i = this._templ.conditionals.length-1; i >= 0; i--) { - let ci = i % colors.length; - innerHTML += '' - } - if (this._templ.conditionals.length == 0) { + if (this._templ.conditionals == null || this._templ.conditionals.length == 0) { this._conditionalsLabel.classList.add("unfocused"); } else { + for (let i = this._templ.conditionals.length-1; i >= 0; i--) { + let ci = i % colors.length; + innerHTML += '' + } this._conditionalsLabel.classList.remove("unfocused"); - } - this._conditionals.innerHTML = innerHTML - buttons = this._conditionals.querySelectorAll("span.button") as NodeListOf; - for (let i = 0; i < this._templ.conditionals.length; i++) { - buttons[i].innerHTML = `{if ` + this._templ.conditionals[i].slice(1) + ``; - buttons[i].onclick = () => { - this.insert(this._textArea, "{if " + this._templ.conditionals[i].slice(1) + "{endif}"); - this.loadPreview(); - // this._timeout = setTimeout(this.loadPreview, this._finishInterval); + this._conditionals.innerHTML = innerHTML + buttons = this._conditionals.querySelectorAll("span.button") as NodeListOf; + for (let i = 0; i < this._templ.conditionals.length; i++) { + buttons[i].innerHTML = `{if ` + this._templ.conditionals[i].slice(1) + ``; + buttons[i].onclick = () => { + this.insert(this._textArea, "{if " + this._templ.conditionals[i].slice(1) + "{endif}"); + this.loadPreview(); + // this._timeout = setTimeout(this.loadPreview, this._finishInterval); + } } } - window.modals.editor.show(); } })