portbay-erb-stamper

Stamps Rails ERB templates with data-pb-loc="<path>:<line>:<col>" so PortBay's visual editor can resolve an element in the browser back to the exact tag in your .html.erb source — which turns on precise mapping, structural editing, and style edits that land in your source rather than an override sheet.

Development-only. Nothing is emitted outside Rails.env.development? unless you say so.

Install

Add it to the :development group and restart. Rails loads the Railtie, which registers the ERB handler; there is nothing else to wire.

Configuration

PORTBAY_LOC overrides the default in both directions — PORTBAY_LOC=0 in the shell turns stamping off, PORTBAY_LOC=1 turns it on outside development. Unlike php artisan serve, bin/rails server boots in-process and does not drop shell environment variables, so the shell form is enough.

What is stamped

Elements written as literal markup in an .html.erb template, including through partials, layouts, content_for blocks and collection rendering — each template is stamped in its own source, so every fragment carries the coordinate of the file it was written in.

Elements built in Ruby rather than written as markup (tag.div, content_tag, link_to) have no source tag to stamp and are left alone; PortBay resolves those by text search, as it does for an un-instrumented project. .text.erb, .json.erb and .js.erb are never touched.

Attributes are only ever inserted, never removed or reordered, so the worst failure mode is a missing stamp rather than a corrupted template.