Module: Redpen::RailHelper
- Defined in:
- app/helpers/redpen/rail_helper.rb
Instance Method Summary collapse
-
#redpen_inject(document, path: request.path) ⇒ Object
The pen on a document the host serves verbatim, with its own
and no layout. -
#redpen_rail(path: request.path) ⇒ Object
The pen on a page the host lays out.
Instance Method Details
#redpen_inject(document, path: request.path) ⇒ Object
The pen on a document the host serves verbatim, with its own
and no layout. Splices the rail before , or appends it when the document has none. From a controller:render html: helpers.redpen_inject(document).html_safe, layout: false.
16 17 18 19 |
# File 'app/helpers/redpen/rail_helper.rb', line 16 def redpen_inject(document, path: request.path) rail = render("redpen/notes/standalone", path: path) document.match?(%r{</body>}i) ? document.sub(%r{</body>}i) { "#{rail}</body>" } : document + rail end |
#redpen_rail(path: request.path) ⇒ Object
The pen on a page the host lays out. One line in the layout, for whoever may pen:
<%= redpen_rail if signed_in? %>
Render it as the last child of
: an ancestor with transform or overflow would clip the pins.
9 10 11 |
# File 'app/helpers/redpen/rail_helper.rb', line 9 def redpen_rail(path: request.path) render "redpen/notes/rail", path: path end |