Class: Maglove::Widget::V1

Inherits:
Base
  • Object
show all
Defined in:
lib/maglove/widget.rb

Instance Attribute Summary

Attributes inherited from Base

#options, #scope

Instance Method Summary collapse

Methods inherited from Base

#defaults, #identifier, #initialize, #style_string

Constructor Details

This class inherits a constructor from Maglove::Widget::Base

Instance Method Details

#drop_containerObject



78
79
80
# File 'lib/maglove/widget.rb', line 78

def drop_container
  haml_tag :div, class: '_typeloft_widget_drop_container'
end

#render(&block) ⇒ Object



72
73
74
75
76
# File 'lib/maglove/widget.rb', line 72

def render(&block)
  haml_tag :div, widget_options do
    yield self if block_given?
  end
end

#widget_optionsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/maglove/widget.rb', line 56

def widget_options
  attributes = {
    :class => "_typeloft_widget",
    :"data-widget-identifier" => identifier
  }
  @options.each do |k, v|
    if [:padding, :margin].include?(k)
      [:top, :right, :bottom, :left].each do |dir|
        attributes["data-attribute-#{k}_#{dir}"] = v
      end
    end
    attributes["data-attribute-#{k}"] = v
  end
  attributes
end