Module: RailsExtras::Helpers::Tag
- Defined in:
- lib/rails_extras/helpers/tag.rb
Instance Method Summary collapse
- #add_link(name = nil, options = nil, html_options = nil, &block) ⇒ Object
- #add_tag(name = nil, options = {}, &block) ⇒ Object
Instance Method Details
#add_link(name = nil, options = nil, html_options = nil, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rails_extras/helpers/tag.rb', line 35 def add_link(name = nil, = nil, = nil, &block) if block_given? if block.arity == 1 link_to(name, ) do add_tag do |tag| block.call(tag) end end else link_to(name, ) do block.call end end else link_to(name, , ) end end |
#add_tag(name = nil, options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rails_extras/helpers/tag.rb', line 4 def add_tag(name=nil, ={}, &block) if block_given? if block.arity == 1 result = ActiveSupport::SafeBuffer.new def result.space(text) self << text self << ' ' end def result.add(text) self << text end block.call(result) if name content_tag(name, ) do result end else result end else if name content_tag(name, ) do block.call end else block.call end end end end |