rails
rails copied to clipboard
Custom route formatters
Summary
To allow for custom route renderers (to add colour, emoji, or additional route filtering) via the rails routes
command, this PR adds formatter registration to the ConsoleFormatters module.
The Sheet
and Expanded
formatters are now SheetFormatter
and ExpandedFormatter
and are both registered formatters.
Other Information
I've written a small demo gem which you can see here
which registers an emoji formatter and renders this output when running rails routes --formatter emoji
:

Generating the output of the routes
command via a custom formatter means we can add additional flags, like --compact
which strips out certain routes like those that belong to action_mailbox, turbo etc)
Very related: #45241, it may be worth trying to work together on this one
Very related: #45241, it may be worth trying to work together on this one
Thanks @skipkayhil I'll follow up on that PR 👍