Sha256: 72189a0ea28fcb68612160e8cb1a07275f56f529aa37f4d0ecace8f6a5ed5a64

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module StrongPresenter
  # Provides the {#helpers} method used in {Presenter} and {CollectionPresenter}
  # to call the Rails helpers.

  # Copy of Draper::ViewHelpers
  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
        StrongPresenter::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
      StrongPresenter::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

4 entries across 4 versions & 1 rubygems

Version Path
strong_presenter-0.2.2 lib/strong_presenter/view_helpers.rb
strong_presenter-0.2.1 lib/strong_presenter/view_helpers.rb
strong_presenter-0.2.0 lib/strong_presenter/view_helpers.rb
strong_presenter-0.1.0 lib/strong_presenter/view_helpers.rb