From 3abb76824b87ad7142e43d764ef09bac73c2066d Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 6 Jan 2013 11:19:24 -0200 Subject: Move table routes formatter class to the inspector and rename it It feels more consistent to have this class called "HtmlTableFormatter", and to have it here with the routes inspector and console formatter, since it's used for both routing error exceptions and the rails info page. --- actionpack/lib/action_dispatch/routing/inspector.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb index e607f8b8d5..9a5c3a5319 100644 --- a/actionpack/lib/action_dispatch/routing/inspector.rb +++ b/actionpack/lib/action_dispatch/routing/inspector.rb @@ -141,5 +141,23 @@ module ActionDispatch end end end + + class HtmlTableFormatter + def initialize(view) + @view = view + @buffer = [] + end + + def section(type, title, routes) + @buffer << %(#{title}) + @buffer << @view.render(partial: "routes/route", collection: routes) + end + + def result + @view.raw @view.render(layout: "routes/route_wrapper") { + @view.raw @buffer.join("\n") + } + end + end end end -- cgit v1.2.3