Sha256: 451a7f4be0a2ce3654ec074d9fd233dbd1f18a3ab8119a3a7ece9896af4d6d1d

Contents?: true

Size: 1020 Bytes

Versions: 8

Compression:

Stored size: 1020 Bytes

Contents

module TaoOnRails
  module ActionView
    module Helpers

      include ::ActionView::Helpers
      include ::ActionView::Context

      def page_id
        controller_names = controller_path.split('/')
        [controller_names, action_name].compact.flatten.join('-')
      end

      def icon_tag(name, attributes = {})
        if attributes[:class].present?
          attributes[:class] += " icon icon-#{name}"
        else
          attributes[:class] = "icon icon-#{name}"
        end

        use_tag = %Q(<use xlink:href="#icon-#{name}"/>).html_safe
        content_tag(:svg, use_tag, attributes).html_safe
      end

      def tao_page(tag,  attributes = nil, &block)
        if tag.is_a? Hash
          attributes = tag
          tag = "#{page_id.dasherize}-page"
        end

        if attributes[:class].present?
          attributes[:class] += " tao-page"
        else
          attributes[:class] = "tao-page"
        end

        content_tag(tag, capture(&block), attributes)
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tao_on_rails-0.6.12 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.11 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.10 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.9 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.8 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.7 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.6 lib/tao_on_rails/action_view/helpers.rb
tao_on_rails-0.6.5 lib/tao_on_rails/action_view/helpers.rb