How to assign data returned to a variable or check data exist after calling django template filter

@register.filter

def sub_menu_count(value,arg): #

test_val=1

key="sub_menu_"+str(arg)

if(len(value[key])>0):

    return value[key]

Am using above code to return a list from the directory, and i need to check whether the returned list is empty or not from the template page.how to do that.
This is the dictionary data.
{‘sub_menu_1’: [(2, ‘IPX Details’, 1, None, None), (4, ‘Signalling IPs’, 1, ‘master/IPX_signalling_ip.html’, None), (5, ‘Media IPs’, 1, ‘master/IPX_media_ip.html’, None)], ‘sub_menu_3’: []}

The below is how i call the filter tag,i dont know how to use if condition here

{{result_data.sub_menu |sub_menu_count:key}}

See the template if tag, and remember that in Python, an empty list evaluates to False.

@KenWhitesell
I have updated the question, in template how can I use IF tag?

Please read the referenced documentation and give it a try. The first example should give you some ideas to work with.