Module: RatPack::Tag
- Defined in:
- lib/ratpack/tag.rb
Instance Method Summary collapse
- #close_tag(name) ⇒ Object
- #open_tag(name, attrs = nil) ⇒ Object
- #self_closing_tag(name, attrs = nil) ⇒ Object
- #tag(name, contents = nil, attrs = {}, &block) ⇒ Object
Instance Method Details
#close_tag(name) ⇒ Object
13 14 15 |
# File 'lib/ratpack/tag.rb', line 13 def close_tag(name) "</#{name}>" end |
#open_tag(name, attrs = nil) ⇒ Object
9 10 11 |
# File 'lib/ratpack/tag.rb', line 9 def open_tag(name, attrs = nil) "<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>" end |
#self_closing_tag(name, attrs = nil) ⇒ Object
17 18 19 |
# File 'lib/ratpack/tag.rb', line 17 def self_closing_tag(name, attrs = nil) "<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>" end |
#tag(name, contents = nil, attrs = {}, &block) ⇒ Object
3 4 5 6 7 |
# File 'lib/ratpack/tag.rb', line 3 def tag(name, contents = nil, attrs = {}, &block) attrs, contents = contents, nil if contents.is_a?(Hash) # contents = capture(&block) if block_given? open_tag(name, attrs) + contents.to_s + close_tag(name) end |