Can't this be done with #theme_wrapper and attributes?