It might be easier to just make this logic part of the clip template, as that's where it actually belongs. This will also make sure that only the necessary elements are rendered.