class
AssetPipeline::FrameworkRegistry
- AssetPipeline::FrameworkRegistry
- Reference
- Object
Overview
The FrameworkRegistry provides an extensible architecture for adding support
for different JavaScript frameworks. This allows the AssetPipeline to support
Stimulus, Alpine.js, Vue, React, and other frameworks in a consistent manner.
This registry pattern ensures clean separation of concerns and provides a standard interface for framework-specific functionality.
Defined in:
asset_pipeline/framework_registry.crClass Method Summary
-
.create_renderer(framework_name : String, import_map : ImportMap, custom_js : String = "")
Creates a renderer instance for the specified framework
-
.detect_framework(import_name : String) : String | Nil
Determines which framework an import name belongs to based on registered patterns
-
.get_core_import(framework_name : String) : String | Nil
Returns the core import name for a framework (e.g., "@hotwired/stimulus")
-
.get_framework_metadata(framework_name : String) : Hash(String, String) | Nil
Returns metadata for a registered framework
-
.get_renderer(framework_name : String) : String | Nil
Returns the renderer class name for a given framework name
-
.register_builtin_frameworks
Auto-registers built-in framework support
-
.register_framework(name : String, renderer_class_name : String, patterns : Array(Regex) = [] of Regex, core_import : String | Nil = nil, description : String | Nil = nil)
Registers a framework renderer class with the registry
-
.registry_summary
Provides a registry summary for debugging and introspection
-
.supported_frameworks : Array(String)
Returns all registered framework names
-
.validate_renderer(renderer_class_name : String) : Bool
Validates that a framework renderer implements required methods
Class Method Detail
Creates a renderer instance for the specified framework
renderer = FrameworkRegistry.create_renderer("stimulus", import_map, custom_js)
Determines which framework an import name belongs to based on registered patterns
FrameworkRegistry.detect_framework("HelloController") # => "stimulus"
FrameworkRegistry.detect_framework("alpine-component") # => "alpine"
Returns the core import name for a framework (e.g., "@hotwired/stimulus")
FrameworkRegistry.get_core_import("stimulus") # => "@hotwired/stimulus"
Returns metadata for a registered framework
FrameworkRegistry.get_framework_metadata("stimulus")
# => {"core_import" => "@hotwired/stimulus", "description" => "Hotwired Stimulus framework support"}
Returns the renderer class name for a given framework name
renderer_class_name = FrameworkRegistry.get_renderer("stimulus")
Auto-registers built-in framework support
This method is called during module initialization to register the frameworks that are bundled with AssetPipeline
Registers a framework renderer class with the registry
FrameworkRegistry.register_framework(
"stimulus",
"AssetPipeline::Stimulus::StimulusRenderer",
patterns: [/Controller$/],
core_import: "@hotwired/stimulus",
description: "Hotwired Stimulus framework support"
)
Provides a registry summary for debugging and introspection
FrameworkRegistry.registry_summary
# => {
# "frameworks" => ["stimulus", "alpine"],
# "total_patterns" => 3,
# "details" => {...}
# }
Returns all registered framework names
FrameworkRegistry.supported_frameworks
# => ["stimulus", "alpine", "vue"]
Validates that a framework renderer implements required methods
This is used during framework registration to ensure compatibility