Module: Upkeep::Rails::ActionViewCapture::ViewHelpers
- Defined in:
- lib/upkeep/rails/action_view_capture.rb
Constant Summary collapse
- UPKEEP_FRAME_BLOCK_ERROR =
"upkeep_frame requires a block. Use: " \ '<%= upkeep_frame("frame-name") do %> ... <% end %>'
Instance Method Summary collapse
-
#upkeep_frame(site_id, manifest_path: nil, manifest_fingerprint: nil, &block) ⇒ String, ActiveSupport::SafeBuffer
Advanced escape hatch for a custom render-site frame.
-
#upkeep_frame_id ⇒ String
Returns the stable DOM id for the current fragment frame.
-
#upkeep_page_frame_id ⇒ String
Returns the stable DOM id for the current page frame.
Instance Method Details
#upkeep_frame(site_id, manifest_path: nil, manifest_fingerprint: nil, &block) ⇒ String, ActiveSupport::SafeBuffer
Advanced escape hatch for a custom render-site frame.
Ordinary Rails ERB does not need this helper. Upkeep instruments safe partial collection renders automatically and inserts the internal markers needed for page, fragment, and render-site delivery.
Use this only when a generated/helper-built boundary cannot be derived from template source. The helper is output-producing and returns the rendered block:
<%= upkeep_frame "cards" do %>
<%= render partial: "cards/card", collection: @cards, as: :card %>
<% end %>
Manual callers are responsible for rendering a stable DOM target for the site. Instrumented templates add that target automatically for normal render sites.
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 |
# File 'lib/upkeep/rails/action_view_capture.rb', line 869 def upkeep_frame(site_id, manifest_path: nil, manifest_fingerprint: nil, &block) raise ArgumentError, UPKEEP_FRAME_BLOCK_ERROR unless block html = Upkeep::Rails::ActionViewCapture.with_render_site( { site_id: site_id, manifest_path: manifest_path, manifest_fingerprint: manifest_fingerprint }.compact ) do capture(&block) end html.respond_to?(:html_safe) ? html.html_safe : html end |
#upkeep_frame_id ⇒ String
Returns the stable DOM id for the current fragment frame.
Normal partials do not need to call this directly; Upkeep’s source instrumentation adds fragment-frame markers while rendering captured partial or fragment templates. This helper is available for custom/generated markup that must emit the marker explicitly.
841 842 843 844 |
# File 'lib/upkeep/rails/action_view_capture.rb', line 841 def upkeep_frame_id Upkeep::Rails::ActionViewCapture.current_frame_id || raise("upkeep_frame_id is only available while rendering an Upkeep frame") end |
#upkeep_page_frame_id ⇒ String
Returns the stable DOM id for the current page frame.
Normal templates do not need to call this directly; Upkeep’s source instrumentation adds page-frame markers while rendering captured page templates. This helper is available for custom/generated markup that must emit the marker explicitly.
827 828 829 830 |
# File 'lib/upkeep/rails/action_view_capture.rb', line 827 def upkeep_page_frame_id Upkeep::Rails::ActionViewCapture.current_frame_id || raise("upkeep_page_frame_id is only available while rendering an Upkeep page frame") end |