Module: AllGems::ViewHelpers
- Included in:
- App
- Defined in:
- lib/allgems/ViewHelpers.rb
Instance Method Summary collapse
- #content_tag(name, content, options, escape = true) ⇒ Object
- #link_to(text, link = nil, options = {}) ⇒ Object
- #link_to_gem(gem, options = {}) ⇒ Object
- #rdocify(text) ⇒ Object
- #tag_options(options, escape = true) ⇒ Object
- #ts(time) ⇒ Object
- #url_for(link_options) ⇒ Object
Instance Method Details
#content_tag(name, content, options, escape = true) ⇒ Object
11 12 13 14 |
# File 'lib/allgems/ViewHelpers.rb', line 11 def content_tag(name, content, , escape = true) = (, escape) if "<#{name}#{}>#{content}</#{name}>" end |
#link_to(text, link = nil, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/allgems/ViewHelpers.rb', line 16 def link_to(text, link = nil, = {}) link ||= text link = url_for(link) "<a href=\"#{link}\">#{text}</a>" end |
#link_to_gem(gem, options = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/allgems/ViewHelpers.rb', line 22 def link_to_gem(gem, = {}) version = [:version] ? [:version] : '' text = [:text] ? [:text] : gem link_to(text, "/gems/#{gem}/#{version}") end |
#rdocify(text) ⇒ Object
43 44 45 46 |
# File 'lib/allgems/ViewHelpers.rb', line 43 def rdocify(text) @_rdoc ||= RDoc::Markup::ToHtml.new @_rdoc.convert(text) end |
#tag_options(options, escape = true) ⇒ Object
6 7 8 9 |
# File 'lib/allgems/ViewHelpers.rb', line 6 def (, escape = true) option_string = .collect {|k,v| %{#{k}="#{v}"}}.join(' ') option_string = " " + option_string unless option_string.blank? end |
#ts(time) ⇒ Object
39 40 41 |
# File 'lib/allgems/ViewHelpers.rb', line 39 def ts(time) time.strftime('%b %d, %Y') if time end |
#url_for(link_options) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/allgems/ViewHelpers.rb', line 28 def url_for() case when Hash path = .delete(:path) || request.path_info params.delete('captures') path + '?' + build_query(params.merge()) else end end |