Sha256: cedaa515622070e48ad5dc552cc9e1c83927539d86b7e33ff03baf4eeada3828

Contents?: true

Size: 959 Bytes

Versions: 5

Compression:

Stored size: 959 Bytes

Contents

module Maglove
  module Widgets
    class Heading < Base
      def identifier
        "heading"
      end

      def defaults
        {
          type: "h1",
          style: "default",
          align: "left",
          margin_bottom: "1em"
        }
      end

      module Helpers
        def heading_widget(options = {}, contents = nil, &block)
          if options.class.name == "String"
            contents = options
            options = {}
          end
          widget_block(Widgets::Heading.new(options)) do |widget|
            haml_tag :header, class: "#{widget.options[:style]} align-#{widget.options[:align]}", style: style_string(widget.options, :margin, :padding) do
              haml_tag widget.options[:type], class: "_typeloft_editable _typeloft_widget_autoselect" do
                haml_concat(contents) if contents
                yield if block
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
maglove-widgets-1.0.4 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.3 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.2 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.1 lib/maglove/widgets/heading.rb
maglove-widgets-1.0.0 lib/maglove/widgets/heading.rb