table: refactored render into smaller methods, added _render_as_json()