module ViewHelper

Public Instance Methods

preact_component(name, props = {}, options = {}, &block) click to toggle source
# 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 content_tag(:div, '', html_options, &block)
end