Refactored item/block template code.