2012-10-16 14:38:51 +00:00
|
|
|
module Draper
|
2013-01-07 16:33:24 +00:00
|
|
|
# Provides the {#helpers} method used in {Decorator} and {CollectionDecorator}
|
|
|
|
# to call the Rails helpers.
|
2012-10-16 14:38:51 +00:00
|
|
|
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
|
2013-01-24 00:23:39 +00:00
|
|
|
Draper::ViewContext.current
|
2012-10-16 14:38:51 +00:00
|
|
|
end
|
2019-05-31 14:08:31 +00:00
|
|
|
|
|
|
|
alias :h :helpers
|
2012-10-16 14:38:51 +00:00
|
|
|
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
|
2013-01-24 00:23:39 +00:00
|
|
|
Draper::ViewContext.current
|
2012-10-16 14:38:51 +00:00
|
|
|
end
|
2019-05-31 14:08:31 +00:00
|
|
|
|
|
|
|
alias :h :helpers
|
2012-10-16 14:38:51 +00:00
|
|
|
|
2013-01-07 16:33:24 +00:00
|
|
|
# Alias for `helpers.localize`, since localize is something that's used
|
|
|
|
# quite often. Further aliased to `l` for convenience.
|
2021-05-27 19:07:37 +00:00
|
|
|
ruby2_keywords def localize(*args)
|
|
|
|
helpers.localize(*args)
|
2012-10-16 14:38:51 +00:00
|
|
|
end
|
2019-05-31 14:08:31 +00:00
|
|
|
|
|
|
|
alias :l :localize
|
2012-10-16 14:38:51 +00:00
|
|
|
end
|
|
|
|
end
|