pixelearth
pixelearth

Reputation: 14630

In Ruby on Rails is there a way to put the path of every partial in an HTML comment?

I work on apps that often have thousands of partials and finding what partial is rendering a section of HTML can be tedious and just waste time.

In development mode, it would sometimes be very helpful to turn on a config to have every partial used be prefaced with its path in an HTML comment so I could quickly know how to access and edit it.

Is there a config option for this or a gem that someone has made for this?

Upvotes: 2

Views: 282

Answers (1)

Ben Pritchard
Ben Pritchard

Reputation: 71

This functionality is built-in to recent rails versions for erb templates.

See here for details: https://blog.saeloun.com/2020/05/11/rails-support-annotates-html-output-with-template-file-names.html

That page mentions another option you could try.

Here is a link to the rails pr that introduced the change: https://github.com/rails/rails/pull/38848

Upvotes: 1

Related Questions