How do I hide categories and/or subcategories if no products assigned?

Tried using the following tokens in the "Sub-category main template" field, but did not work:

%begin_hasproducts%...%end_hasproducts%, and

%begin_hasnoproducts%...%end_hasnoproducts%