Sha256: 298d3340e0f4d90a26e5c0385d801785010d6483fd03ac7d829893314a1c7a0c
Contents?: true
Size: 949 Bytes
Versions: 3
Compression:
Stored size: 949 Bytes
Contents
module Havior class Model attr_reader :html_identifier, :html_classes def initialize id prefix = "havior" components = self.class.name.underscore.split("/")[0..-2] @dir = components.join("/") html_class_name = prefix + "-" + components.join("-") @html_identifier = "#{html_class_name}-#{id}" @html_classes = ["havior", html_class_name] end def javascripts [] end def stylesheets [] end def html ajax_params={}, erb_params={} action_view = ActionView::Base.new "#{Rails.root}/app/haviors/#{@dir}/views" erb_params.each{|k,v| action_view.assign(k=>v) } ajax_params.each{|k,v| action_view.assign(k=>v) } data = ajax_params.map{|k,v| "data-#{k}='#{v}'" }.join(' ') return <<HTML <div id="#{@html_identifier}" class="#{@html_classes.join(' ')}" #{data}> #{action_view.render(template: self.erb_script)} </div> HTML end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
havior-0.1.2 | lib/havior/model.rb |
havior-0.1.1 | lib/havior/model.rb |
havior-0.1.0 | lib/havior/model.rb |