Sha256: 44ba95180c6581ce213f57140be5a89efa93460eae59362821260cde758e1726

Contents?: true

Size: 954 Bytes

Versions: 2

Compression:

Stored size: 954 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 :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 :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 :l :localize
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
draper-4.0.1 lib/draper/view_helpers.rb
draper-4.0.0 lib/draper/view_helpers.rb