Module: Ruact::ErbPreprocessorHook

Defined in:
lib/ruact/erb_preprocessor_hook.rb

Overview

Module prepended into ActionView::Template::Handlers::ERB via Railtie. Applies the RSC preprocessor to every ERB template source before ActionView compiles it — transparent to views, layouts, and partials.

ErbPreprocessor.transform has a fast-path O(1) return when the source contains no PascalCase tags, so non-RSC templates pay essentially no cost.

Idempotent: prepend is a no-op if this module is already in the ancestor chain, so reloads in development mode are safe.

Instance Method Summary collapse

Instance Method Details

#call(template, source) ⇒ Object

Called by ActionView for every ERB template. source is the raw ERB text; the return value is Ruby code that ActionView will eval.



16
17
18
19
20
21
# File 'lib/ruact/erb_preprocessor_hook.rb', line 16

def call(template, source)
  # Story 13.5 — forward +template.identifier+ (the template file path) so a
  # component-contract violation can name the call site's file:line. The
  # contract registry defaults to the process-loaded +Ruact.manifest+.
  super(template, ErbPreprocessor.transform(source, identifier: template.identifier))
end