Class: WebComponentsRails::HTMLImportProcessor
- Inherits:
-
Object
- Object
- WebComponentsRails::HTMLImportProcessor
- Defined in:
- lib/web_components_rails/html_import_processor.rb
Overview
Processes web component HTML files that contains imports See also:
https://github.com/rails/sprockets/blob/master/UPGRADING.md
https://github.com/rails/sprockets/blob/3.x/lib/sprockets/directive_processor.rb
Constant Summary collapse
- VERSION =
'9'
Instance Attribute Summary collapse
-
#cache_key ⇒ Object
readonly
Returns the value of attribute cache_key.
Class Method Summary collapse
Instance Method Summary collapse
- #call(input) ⇒ Object
-
#initialize(options = {}) ⇒ HTMLImportProcessor
constructor
A new instance of HTMLImportProcessor.
Constructor Details
#initialize(options = {}) ⇒ HTMLImportProcessor
Returns a new instance of HTMLImportProcessor.
25 26 27 |
# File 'lib/web_components_rails/html_import_processor.rb', line 25 def initialize( = {}) @cache_key = [self.class.name, VERSION, ].freeze end |
Instance Attribute Details
#cache_key ⇒ Object (readonly)
Returns the value of attribute cache_key.
23 24 25 |
# File 'lib/web_components_rails/html_import_processor.rb', line 23 def cache_key @cache_key end |
Class Method Details
.cache_key ⇒ Object
19 20 21 |
# File 'lib/web_components_rails/html_import_processor.rb', line 19 def self.cache_key instance.cache_key end |
.call(input) ⇒ Object
15 16 17 |
# File 'lib/web_components_rails/html_import_processor.rb', line 15 def self.call(input) instance.call(input) end |
.instance ⇒ Object
11 12 13 |
# File 'lib/web_components_rails/html_import_processor.rb', line 11 def self.instance @instance ||= new end |
Instance Method Details
#call(input) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/web_components_rails/html_import_processor.rb', line 29 def call(input) # Sprockets::Environment for looking up assets, etc. @environment = input[:environment] @context = @environment.context_class.new(input) @data = input[:data] @filename = input[:filename] @dirname = File.dirname(@filename) @data, paths = process_imports(@data, @dirname) paths.each do |path| @context.require_asset(path) end @context..merge(data: @data) end |