mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Template for ApplicationDecorator
This commit is contained in:
parent
f4d162159d
commit
19fc9fcbbf
1 changed files with 28 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
class ApplicationDecorator < Draper::Base
|
||||
# Lazy Helpers
|
||||
# PRO: Call Rails helpers without the h. proxy
|
||||
# ex: number_to_currency(model.price)
|
||||
# CON: Add a bazillion methods into your decorator's namespace
|
||||
# and probably sacrifice performance/memory
|
||||
#
|
||||
# Enable them by uncommenting this line:
|
||||
# include Draper::LazyHelpers
|
||||
|
||||
# Shared Decorations
|
||||
# Consider defining shared methods common to all your models.
|
||||
#
|
||||
# Example: standardize the formatting of timestamps
|
||||
#
|
||||
# def formatted_timestamp(time)
|
||||
# content_tag :span, time.strftime("%a %m/%d/%y"),
|
||||
# :class => 'timestamp'
|
||||
# end
|
||||
#
|
||||
# def created_at
|
||||
# formatted_timestamp(model.created_at)
|
||||
# end
|
||||
#
|
||||
# def updated_at
|
||||
# formatted_timestamp(model.updated_at)
|
||||
# end
|
||||
end
|
Loading…
Add table
Reference in a new issue