refactors attribute rendering to avoid duplication