Re: Output only when the outputclass is set, otherwise do not output any HTML
I tried to do a similar thing a couple years ago - remove a <draftintro> topic from a bookmap when args.draft == no.
I found that profiling attributes have dedicated machinery to remove filtered topics from the .job.xml file in the temporary directory, which contains the list of topic/image files to be processed and published.
You can read about my struggles here:
I eventually gave up and applied profiling conditions to my <draftintro> elements, in parallel with setting args.draft to keep/remove <draft-comment> elements within topics. It felt unnecessarily redundant but it worked.
I know you said that profiling attributes are not an option for you, but maybe some part of my struggles above might help you figure out a solution to your own situation.