Module: Gretel::HelperMethods
- Includes:
- ActionView::Helpers::UrlHelper
- Defined in:
- lib/gretel/helper_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
- #breadcrumb(*args) ⇒ Object
- #breadcrumb_for(*args) ⇒ Object
-
#controller ⇒ Object
hack because ActionView::Helpers::UrlHelper needs a controller method.
Class Method Details
.included(base) ⇒ Object
7 8 9 |
# File 'lib/gretel/helper_methods.rb', line 7 def self.included(base) base.send :helper_method, :breadcrumb_for, :breadcrumb end |
Instance Method Details
#breadcrumb(*args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gretel/helper_methods.rb', line 11 def (*args) = args. name, object = args[0], args[1] if name = name = object else if crumb = (, , ) elsif [:show_root_alone] crumb = (:root, ) end end if crumb && [:pretext] crumb = [:pretext].html_safe + " " + crumb end crumb end |
#breadcrumb_for(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gretel/helper_methods.rb', line 33 def (*args) = args. link_last = [:link_last] [:link_last] = true separator = ([:separator] || ">").html_safe name, object = args[0], args[1] crumb = Crumbs.get_crumb(name, object) out = link_to_if(link_last, crumb.link.text, crumb.link.url) while parent = crumb.parent last_parent = parent.name crumb = Crumbs.get_crumb(parent.name, parent.object) out = link_to(crumb.link.text, crumb.link.url) + " " + separator + " " + out end # TODO: Refactor this if [:autoroot] && name != :root && last_parent != :root crumb = Crumbs.get_crumb(:root) out = link_to(crumb.link.text, crumb.link.url) + " " + separator + " " + out end out end |
#controller ⇒ Object
hack because ActionView::Helpers::UrlHelper needs a controller method
4 5 |
# File 'lib/gretel/helper_methods.rb', line 4 def controller # hack because ActionView::Helpers::UrlHelper needs a controller method end |