Can I dynamically I display only categories and/or subcategories with assigned products in Category Page Template? If so, how?

I 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%