Refactor style and attr handling into re-usable helper method