Sha256: a28fd15fcac2c461c6e7a4a2b082bf83e23bc568ef3e497513f464502d661bdc

Contents?: true

Size: 1.82 KB

Versions: 57

Compression:

Stored size: 1.82 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

      # Treats all input to \{Haml::Helpers#haml\_concat} within the block
      # as being HTML safe for Rails' XSS protection.
      # This is useful for wrapping blocks of code that concatenate HTML en masse.
      #
      # This has no effect if Rails' XSS protection isn't enabled.
      #
      # @yield A block in which all input to `#haml_concat` is treated as raw.
      # @see Haml::Util#rails_xss_safe?
      def with_raw_haml_concat
        @_haml_concat_raw, old = true, @_haml_concat_raw
        yield
      ensure
        @_haml_concat_raw = old
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
haml-edge-2.3.209 lib/haml/helpers/action_view_extensions.rb
haml-3.0.0.beta.3 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.208 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.207 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.206 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.205 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.204 lib/haml/helpers/action_view_extensions.rb
haml-3.0.0.beta.2 lib/haml/helpers/action_view_extensions.rb
haml-2.2.23 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.203 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.202 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.201 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.200 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.199 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.198 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.197 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.196 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.195 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.194 lib/haml/helpers/action_view_extensions.rb
haml-edge-2.3.193 lib/haml/helpers/action_view_extensions.rb