I am looking for a gem or elegant way to setup system where I would be able to see where certain HTML content came from. I am working on a big project, and a lot of my times goes determining where a certain piece of HTML content came from. I know you are able to see which layouts, partials are used to render a page in logs but I am looking for something more practical.
An example of this would be.
<!-- ... app/views/layouts/main.html.slim -->
<body>
<!-- ... app/views/people/index.html.slim -->
<div class="foo">
<table clas="items">
<!-- ... app/views/people/shared/_person.html.slim -->
<td>
<span>John Doe</span>
</td>
</table>
</div>
</body>
Where before rendering any partial / page / layout rails render engine would add a comment describing origin.
Maybe this rails_view_annotator
gem would be a good starting point:
The Rails View Annotator wraps the rendering of Rails partials with html comments indicating the disk location of the rendered partial.
According to the project README, the gem will output rendered content like this:
<!-- begin: app/views/user/_bio.html.haml (from app/views/user/show.html.haml:4) -->
<div class='bio'>Ed's Bio</div>
<!-- end: app/views/user/_bio.html.haml (from app/views/user/show.html.haml:4) -->
However, it doesn't look like it's in active development so might not be compatible with recent Rails versions, YMMV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With