You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I only found ONE example of an if-condition in the docs (Templating). So I have to try for myself how listmonks if-conditions works. My current example:
At the end of a personal mail I want to write:
"Greetings." --> if current subscriber has an empty attribute {{.Subscrier.Attribs.city}}
"Greetings to London." --> if subscriber already has a value ("London") in this attribute.
So I tried following (similar to the example in the docs):
{{ if eq .Subscriber.Attribs.city "" }}
Greetings.
{{ else }}
Greetings to {{ .Suscriber.Attribs.city }}
{{ end }}
But on previewing I got the error "{template: content:7:123: executing "content" at \u003c.Suscriber.Attribs.city\u003e: can't evaluate field Suscriber in type *manager.CampaignMessage"}".
I have discovered that if I remove the second "{{ .Suscriber.Attribs.city }}", there is no error.
I note that only text, but no variables, can be output in if-conditions. If this is right, I find it very poor.
So I guess that nested if-conditions are impossible ...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi listmonkers,
I only found ONE example of an if-condition in the docs (Templating). So I have to try for myself how listmonks if-conditions works. My current example:
At the end of a personal mail I want to write:
So I tried following (similar to the example in the docs):
{{ if eq .Subscriber.Attribs.city "" }}
Greetings.
{{ else }}
Greetings to {{ .Suscriber.Attribs.city }}
{{ end }}
But on previewing I got the error "{template: content:7:123: executing "content" at \u003c.Suscriber.Attribs.city\u003e: can't evaluate field Suscriber in type *manager.CampaignMessage"}".
I have discovered that if I remove the second "{{ .Suscriber.Attribs.city }}", there is no error.
I note that only text, but no variables, can be output in if-conditions. If this is right, I find it very poor.
So I guess that nested if-conditions are impossible ...
Has anyone experience with if-conditions yet?
Greetings {{to all}} ;-)
Suzi
Beta Was this translation helpful? Give feedback.
All reactions