Module: ViewComponentSubtemplates::StandaloneRenderer
- Defined in:
- lib/view_component_subtemplates/standalone_renderer.rb
Overview
Renders one subtemplate on its own (no main template), e.g. to serve a fragment from a controller. The subtemplate-level counterpart of ‘render_in`. Requires a no-locals subtemplate: per-render data goes through the constructor.
Instance Method Summary collapse
-
#render_subtemplate_in(view_context, name) ⇒ String
The subtemplate’s HTML (html_safe).
Instance Method Details
#render_subtemplate_in(view_context, name) ⇒ String
Returns the subtemplate’s HTML (html_safe).
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/view_component_subtemplates/standalone_renderer.rb', line 11 def render_subtemplate_in(view_context, name) self.class.__vc_compile(raise_errors: true) ensure_renderable_subtemplate!(name) # Set up the view context the helper guards require. `__vc_original_view_context` # makes `helpers` reuse it instead of building a new one (keep both). @view_context = view_context self.__vc_original_view_context = view_context public_send("call_#{name}") end |