-1

I need to setup a jinja2 template that does this...

"message":"{{ policy.message | default('{{message}}') }}"

If you don't provide anything to override the message, the json template should take a value of {{message}}.

I've tried a couple of things, but I can't seem to get it to work. It keeps returning this error...

'message' is undefined

Any ideas?

1 Answers1

-1

I think I figured it out.

"message":"{{ policy.message | default('{{message}}') }}"

This line does work. It does add it as needed. The problem I was encountering was a post-verification check to print this render out acted as if there was an undefined var. Essentially it renders the template again. Looks like I just need to make that a literal print instead of render and that fixes my problem. Thanks all.

  • 1
    why answering a question that already have many answers with a very hi score if you cannot provide something better ? Plz follow SO policy. – Valery S. Oct 05 '22 at 15:33