I have array constructed like this
add_to_context('custom', [
[
'title' => 'My title',
'link' => 'My link'
],
[
'title' => 'My title 1',
'link' => 'My link 1'
]
]);
and in view I have simple loop
{% for item in custom %}
<li>
<h1>{{ item.title }}
<img src="{{ item.link|e }}" target="_blank">
</li>
{% endfor %}
And everything works fine. But I want to print elements which have both keys with value. For example, if I have
[
'title' => '',
'link' => 'mylink'
]
I don't want to print this. If link will be empty I don't want it too. If both are empty - the same. I want to print it only if both keys have values. So, how can I do this?
if.{% if item.title is not empty && item.link is not empty %} .... Ofc if you want more validation you can also check if defined, although it's not really necessary if you're absolutely sure that the values exist.