Module: DuffyHelper
- Defined in:
- lib/duffy/duffy_helper.rb
Instance Method Summary collapse
-
#excel_icon(link = params.merge(format: "xlsx")) ⇒ Object
Create Excel icon in consistent location This is intended to display the xlsx version of a view.
-
#icon(title, link, options = {}) ⇒ Object
Create a simple link with the class “icon” Generate a uniq and reasonable id based on the link passed (if any) Add any classes passed in via options Add the “favorite” class if icon is favorited - This is application specific and will just not do anything if it runs into a problem If any uncaught exceptions are thrown in production you’ll just get nothing, otherwise you’ll get the error on screen.
-
#menu_tag(title, link, options = {}) ⇒ Object
This creates menu entries in the format Zurb Foundation expects.
Instance Method Details
#excel_icon(link = params.merge(format: "xlsx")) ⇒ Object
Create Excel icon in consistent location This is intended to display the xlsx version of a view. Add a yield(:excel) somewhere in your application layout:
content_tag( :li, yield(:excel), class: :excel) if content_for?(:excel)
14 15 16 17 18 |
# File 'lib/duffy/duffy_helper.rb', line 14 def excel_icon(link = params.merge(format: "xlsx")) content_for :excel do link_to(image_tag('excel.png'), link) end end |
#icon(title, link, options = {}) ⇒ Object
Create a simple link with the class “icon” Generate a uniq and reasonable id based on the link passed (if any) Add any classes passed in via options Add the “favorite” class if icon is favorited
- This is application specific and will just not do anything if it runs into a problem
If any uncaught exceptions are thrown in production you’ll just get nothing, otherwise you’ll get the error on screen.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/duffy/duffy_helper.rb', line 26 def icon(title, link, = {}) begin [:id] = "icon_#{link.parameterize("_")}" unless link.blank? [:class] = [:icon] << [:class] [:class] << :favorite if defined?(current_user) and (current_user.person.details.where(key: "favorite_#{[:id]}").any? rescue false) [:class] = [:class].flatten.compact link_to(title, link, ) rescue Exception => e Rails.env.development? ? content_tag(:p, e) : nil end end |
#menu_tag(title, link, options = {}) ⇒ Object
This creates menu entries in the format Zurb Foundation expects. It’s just an <li> with a link inside it. menu_tag(‘Help’, help_path) => <li><a href=“/help”>Help</a></li>
6 7 8 |
# File 'lib/duffy/duffy_helper.rb', line 6 def (title, link, = {}) content_tag(:li, link_to(title, link), ) end |