Module: Merb::Helpers::Tag
- Included in:
- GlobalHelpers, Form::Builder::Base
- Defined in:
- merb-helpers/lib/merb-helpers/tag_helpers.rb
Instance Method Summary (collapse)
-
- (Object) close_tag(name)
Creates a closing tag.
-
- (Object) open_tag(name, attrs = nil)
Creates the opening tag with attributes for the provided name.
-
- (Object) self_closing_tag(name, attrs = nil)
Creates a self closing tag.
-
- (Object) tag(name, contents = nil, attrs = {}, &block)
Creates a generic HTML tag.
Instance Method Details
- (Object) close_tag(name)
Creates a closing tag.
48 49 50 |
# File 'merb-helpers/lib/merb-helpers/tag_helpers.rb', line 48 def close_tag(name) "</#{name}>" end |
- (Object) open_tag(name, attrs = nil)
Note:
This tag will need to be closed
Creates the opening tag with attributes for the provided name.
41 42 43 |
# File 'merb-helpers/lib/merb-helpers/tag_helpers.rb', line 41 def open_tag(name, attrs = nil) "<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>" end |
- (Object) self_closing_tag(name, attrs = nil)
Creates a self closing tag. Like <br/> or <img src="..."/>
55 56 57 |
# File 'merb-helpers/lib/merb-helpers/tag_helpers.rb', line 55 def self_closing_tag(name, attrs = nil) "<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>" end |
- (Object) tag(name, contents = nil, attrs = {}, &block)
Creates a generic HTML tag. You can invoke it a variety of ways.
28 29 30 31 32 |
# File 'merb-helpers/lib/merb-helpers/tag_helpers.rb', line 28 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 |