Sha256: 0bdf29f34824130a7773c3b5311d6492800bd6eff7a71a5fac3d65528ab96bf8

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 KB

Contents

require 'haml/helpers/action_view_mods'

module Haml
  module Helpers
    # This module contains various useful helper methods
    # that either tie into ActionView or the rest of the ActionPack stack,
    # or are only useful in that context.
    # Thus, the methods defined here are only available
    # if ActionView is installed.
    module ActionViewExtensions
      # Returns a value for the "class" attribute
      # unique to this controller/action pair.
      # This can be used to target styles specifically at this action or controller.
      # For example, if the current action were `EntryController#show`,
      #
      #     %div{:class => page_class} My Div
      #
      # would become
      #
      #     <div class="entry show">My Div</div>
      #
      # Then, in a stylesheet (shown here as {Sass}),
      # you could refer to this specific action:
      #
      #     .entry.show
      #       :font-weight bold
      #
      # or to all actions in the entry controller:
      #
      #     .entry
      #       :color #00f
      #
      # @return [String] The class name for the current page
      def page_class
        controller.controller_name + " " + controller.action_name
      end
      alias_method :generate_content_class_names, :page_class
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
haml-edge-2.1.25 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.26 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.27 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.28 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.29 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.30 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.32 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.33 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.24 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.23 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.1.22 lib/haml/helpers/action_view_extensions.rb