Hi All,
Just wondering if there are any Jinja gurus about, i seem to be having a daft issue with my Jinja templating. I've tried every obvious syntax but can't seem to get it right.
I'm essentially want to do an If statement within a for loop, the if conditional is to check whether item.port == a declared value. If I manually set the value in the if statement it works, but passing the value in as a var doesn't. I suspect I'm not getting the syntax on the if correct.
{% set targetport = %}
Target Port: {{ targetport }}
{% for item in EntityResult|sort(attribute="qid")%}
{% if item.port == targetport %}
The above shows the if condition. I've tried using
== {{ targetport }}
all sorts. If i replace
== targetport with == 995
in an alert where that is true, then everything works.
Any recommendations welcomed,
I've replaced the for and if with the following which is more efficient;
{% for item in EntityResult|selectattr(port, equalto ,targetport)|sort(attribute=qid)%}
Though still can't get the var targetport to work, replacing it with "995" works!
solved, dumped the var and quoted the source.
{% for item in EntityResult|selectattr(port, ==, [Event.regex_port] )|sort(attribute=qid)%}