Catch panic in render_template