parent
49952fff8c
commit
de2d62c75a
|
@ -151,7 +151,7 @@ module Draper
|
|||
end
|
||||
|
||||
# Access the helpers proxy to call built-in and user-defined
|
||||
# Rails helpers. Aliased to `.h` for convinience.
|
||||
# Rails helpers. Aliased to `.h` for convenience.
|
||||
#
|
||||
# @return [Object] proxy
|
||||
def helpers
|
||||
|
@ -159,6 +159,14 @@ module Draper
|
|||
end
|
||||
alias :h :helpers
|
||||
|
||||
# Localize is something that's used quite often. Even though
|
||||
# it's available through helpers, that's annoying. Aliased
|
||||
# to `.l` for convenience.
|
||||
def localize(str)
|
||||
self.class.helpers.localize(str)
|
||||
end
|
||||
alias :l :localize
|
||||
|
||||
# Access the helpers proxy to call built-in and user-defined
|
||||
# Rails helpers from a class context.
|
||||
#
|
||||
|
|
|
@ -597,6 +597,12 @@ describe Draper::Base do
|
|||
it "should be able to use the pluralize helper" do
|
||||
decorator.sample_truncate.should == "Once..."
|
||||
end
|
||||
|
||||
it "should be able to use l rather than helpers.l" do
|
||||
now = Time.now
|
||||
decorator.helpers.should_receive(:localize).with(now)
|
||||
decorator.l now
|
||||
end
|
||||
end
|
||||
|
||||
describe "#method_missing" do
|
||||
|
|
Loading…
Reference in New Issue