Module: ViewHelper

Defined in:
lib/preact/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#preact_component(name, props = {}, options = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/preact/view_helper.rb', line 2

def preact_component(name, props = {}, options = {}, &block)
  html_options = options.reverse_merge(:data => {})
  html_options[:data].tap do |data|
    data[:preact_class] = name
    data[:preact_props] = (props.is_a?(String) ? props : props.to_json)
  end

  return (:div, '', html_options, &block)
end