Closed sfcgeorge closed 4 years ago
@sfcgeorge Thanks for the suggestion! I totally agree! We actually already have something similar here: https://github.com/luckyframework/lucky/blob/89f7fda4ab1fb67cf0fd7c2f8897e3ed5f4c0d81/src/lucky/mount_component.cr#L39-L41 but it does not include the file path.
I think it'd be good to add that though! Let me know if you'd like to work on that, otherwise I might pick this up next week
What
A suggestion to add an option (probably on by default in development, off in production) for a data-trace HTML attribute with the path to the view where the element was generated from.
Haml in Ruby has this and it looks like
<div data-trace="/compass/outlets/bookings/step_two/edit.html.haml:3">
. You turn it on in yourdevelopment.rb
Why
It's super useful in large codebases with lots of nested views and custom URLs (non-resourceful) with lots of similar views making it really hard for a new dev (or existing dev) to find where anything is. With this you just right click whatever you're interested in in your browser, "Inspect", and find the path in the HTML.
Etc
Another approach to this is Xray Rails which gives a whole UI for finding where things are, but I think that's overkill. The browser inspector is more than enough for finding the element you're trying to change, and then just look at the
data-trace
to find the file. Someone else could write a framework agnostic browser extension for a fancy UI using thedata-trace
if they wanted.