Jinja templating

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,

0 2 168
2 REPLIES 2