Module: HeadStartRailsHelper
- Defined in:
- lib/head_start/helpers/head_start_rails_helper.rb
Instance Method Summary collapse
-
#button_link_to(button_text, path, options = {}) ⇒ Object
create a link that looks like a button using button_link_to instead of link_to this works exactly the same as link_to, but will automatically apply appropriate styling In addition, passing in one of the following classes will add a suitable icon to the button:.
-
#cancel_link(label = "Cancel") ⇒ Object
the cancel_link helper creates link back to the referring page.
- #context_aware_link_to(name, url, options = {}) ⇒ Object
- #ie_html(attrs = {}, &block) ⇒ Object
-
#ie_tag(name = :body, attrs = {}, &block) ⇒ Object
Create a named haml tag to wrap IE conditional around a block paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither helper courtesy of Peter Gumeson’s html5-boilerplate gem.
Instance Method Details
#button_link_to(button_text, path, options = {}) ⇒ Object
create a link that looks like a button using button_link_to instead of link_to this works exactly the same as link_to, but will automatically apply appropriate styling In addition, passing in one of the following classes will add a suitable icon to the button:
positive negative index new show create edit update destroy back print download
39 40 41 42 43 |
# File 'lib/head_start/helpers/head_start_rails_helper.rb', line 39 def (, path, = {}) = add_class "button", name = "<span>#{button_text}</span>".html_safe link_to name, path, end |
#cancel_link(label = "Cancel") ⇒ Object
the cancel_link helper creates link back to the referring page
46 47 48 |
# File 'lib/head_start/helpers/head_start_rails_helper.rb', line 46 def cancel_link(label = "Cancel") ("or " + link_to( label, :back )).html_safe end |
#context_aware_link_to(name, url, options = {}) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/head_start/helpers/head_start_rails_helper.rb', line 50 def context_aware_link_to(name, url, = {}) link = link_to_unless_current(name, url, ) do |name,url,| = add_class "current", link_to(name,url,) end link.html_safe end |
#ie_html(attrs = {}, &block) ⇒ Object
17 18 19 |
# File 'lib/head_start/helpers/head_start_rails_helper.rb', line 17 def ie_html(attrs={}, &block) ie_tag(:html, attrs, &block) end |
#ie_tag(name = :body, attrs = {}, &block) ⇒ Object
Create a named haml tag to wrap IE conditional around a block paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither helper courtesy of Peter Gumeson’s html5-boilerplate gem
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/head_start/helpers/head_start_rails_helper.rb', line 5 def ie_tag(name=:body, attrs={}, &block) attrs.symbolize_keys! haml_concat("<!--[if lt IE 7]> #{ tag(name, add_class('ie6 oldie', attrs), true) } <![endif]-->".html_safe) haml_concat("<!--[if IE 7]> #{ tag(name, add_class('ie7 oldie', attrs), true) } <![endif]-->".html_safe) haml_concat("<!--[if IE 8]> #{ tag(name, add_class('ie8 oldie', attrs), true) } <![endif]-->".html_safe) haml_concat("<!--[if gt IE 8]><!-->".html_safe) haml_tag name, attrs do haml_concat("<!--<![endif]-->".html_safe) block.call end end |