Sha256: 369b66856a33f37a7cf72312fb1d797478dd49cfb3534f14f7804a1103b85130

Contents?: true

Size: 1.26 KB

Versions: 85

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

85 entries across 85 versions & 3 rubygems

Version Path
drnic-haml-2.3.1 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.51 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.50 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.49 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.48 lib/haml/helpers/action_view_extensions.rb
haml-2.2.8 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.47 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.46 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.45 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.44 lib/haml/helpers/action_view_extensions.rb
drnic-haml-2.3.0 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.43 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.42 lib/haml/helpers/action_view_extensions.rb
haml-2.2.6 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.41 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.40 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.39 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.38 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.37 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.36 lib/haml/helpers/action_view_extensions.rb