Sha256: fd4f38b7240ec76e25d624f3669d4e5550631a4674f4d5030fa148578db3f572

Contents?: true

Size: 978 Bytes

Versions: 14

Compression:

Stored size: 978 Bytes

Contents

module Draper
  # Provides the {#helpers} method used in {Decorator} and {CollectionDecorator}
  # to call the Rails helpers.
  module ViewHelpers
    extend ActiveSupport::Concern

    module ClassMethods

      # Access the helpers proxy to call built-in and user-defined
      # Rails helpers from a class context.
      #
      # @return [HelperProxy] the helpers proxy
      def helpers
        Draper::ViewContext.current
      end
      alias_method :h, :helpers

    end

    # Access the helpers proxy to call built-in and user-defined
    # Rails helpers. Aliased to `h` for convenience.
    #
    # @return [HelperProxy] the helpers proxy
    def helpers
      Draper::ViewContext.current
    end
    alias_method :h, :helpers

    # Alias for `helpers.localize`, since localize is something that's used
    # quite often. Further aliased to `l` for convenience.
    def localize(*args)
      helpers.localize(*args)
    end
    alias_method :l, :localize

  end
end

Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
draper-3.0.1 lib/draper/view_helpers.rb
draper-3.0.0 lib/draper/view_helpers.rb
draper-3.0.0.pre1 lib/draper/view_helpers.rb
draper_new-3.0.0 lib/draper/view_helpers.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/draper-2.1.0/lib/draper/view_helpers.rb
draper-2.1.0 lib/draper/view_helpers.rb
draper-2.0.0 lib/draper/view_helpers.rb
draper-1.4.0 lib/draper/view_helpers.rb
draper-1.3.1 lib/draper/view_helpers.rb
draper-1.3.0 lib/draper/view_helpers.rb
draper-1.2.1 lib/draper/view_helpers.rb
draper-1.2.0 lib/draper/view_helpers.rb
jamesgolick-draper-1.1.1a lib/draper/view_helpers.rb
draper-1.1.0 lib/draper/view_helpers.rb