Module: Ruact::ViewHelper
- Defined in:
- lib/ruact/view_helper.rb
Overview
ActionView helper module included in ActionView::Base via Railtie. Provides the rsc_component method that ERB templates call after the preprocessor transforms PascalCase tags into <%= rsc_component(…) %>.
Thread-safe: ActionView creates a fresh view context per request, so there is no shared state between concurrent requests.
Instance Method Summary collapse
-
#__rsc_component__(name, props = {}) ⇒ Object
Registers
namewithpropsin the per-request ComponentRegistry and returns an HTML comment placeholder that HtmlConverter later replaces with a ReactElement node.
Instance Method Details
#__rsc_component__(name, props = {}) ⇒ Object
Registers name with props in the per-request ComponentRegistry and returns an HTML comment placeholder that HtmlConverter later replaces with a ReactElement node.
The returned string MUST be html_safe so ActionView does not escape the angle brackets — if it were escaped, HtmlConverter would not find the placeholder in the HTML output.
18 19 20 21 |
# File 'lib/ruact/view_helper.rb', line 18 def __rsc_component__(name, props = {}) token = ComponentRegistry.register(name, props) "<!-- #{token} -->".html_safe end |