class AssetPipeline::FrameworkRegistry

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.cr

Class Method Summary

Class Method Detail

def self.create_renderer(framework_name : String, import_map : ImportMap, custom_js : String = "") #

Creates a renderer instance for the specified framework

renderer = FrameworkRegistry.create_renderer("stimulus", import_map, custom_js)

[View source]
def self.detect_framework(import_name : String) : String | Nil #

Determines which framework an import name belongs to based on registered patterns

FrameworkRegistry.detect_framework("HelloController")  # => "stimulus"
FrameworkRegistry.detect_framework("alpine-component") # => "alpine"

[View source]
def self.get_core_import(framework_name : String) : String | Nil #

Returns the core import name for a framework (e.g., "@hotwired/stimulus")

FrameworkRegistry.get_core_import("stimulus")  # => "@hotwired/stimulus"

[View source]
def self.get_framework_metadata(framework_name : String) : Hash(String, String) | Nil #

Returns metadata for a registered framework

FrameworkRegistry.get_framework_metadata("stimulus")
# => {"core_import" => "@hotwired/stimulus", "description" => "Hotwired Stimulus framework support"}

[View source]
def self.get_renderer(framework_name : String) : String | Nil #

Returns the renderer class name for a given framework name

renderer_class_name = FrameworkRegistry.get_renderer("stimulus")

[View source]
def self.register_builtin_frameworks #

Auto-registers built-in framework support

This method is called during module initialization to register the frameworks that are bundled with AssetPipeline


[View source]
def self.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

FrameworkRegistry.register_framework(
  "stimulus",
  "AssetPipeline::Stimulus::StimulusRenderer",
  patterns: [/Controller$/],
  core_import: "@hotwired/stimulus", 
  description: "Hotwired Stimulus framework support"
)

[View source]
def self.registry_summary #

Provides a registry summary for debugging and introspection

FrameworkRegistry.registry_summary
# => {
#   "frameworks" => ["stimulus", "alpine"],
#   "total_patterns" => 3,
#   "details" => {...}
# }

[View source]
def self.supported_frameworks : Array(String) #

Returns all registered framework names

FrameworkRegistry.supported_frameworks
# => ["stimulus", "alpine", "vue"]

[View source]
def self.validate_renderer(renderer_class_name : String) : Bool #

Validates that a framework renderer implements required methods

This is used during framework registration to ensure compatibility


[View source]