Module: Phlexible::ProcessAttributes

Defined in:
lib/phlexible/process_attributes.rb

Overview

rubocop:disable Style/DocumentDynamicEvalDefinition

Defined Under Namespace

Modules: StandardElements, VoidElements

Instance Method Summary collapse

Instance Method Details

#register_element(method_name, tag: method_name.name.tr('_', '-')) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/phlexible/process_attributes.rb', line 8

def register_element(method_name, tag: method_name.name.tr('_', '-'))
  super

  wrapper = Module.new do
    define_method(method_name) do |**attributes, &block|
      attributes = process_attributes(attributes) if respond_to?(:process_attributes)
      super(**attributes, &block)
    end
  end
  prepend wrapper
end