Files

Merb::Helpers::Tag

Public Instance Methods

close_tag(name) click to toggle source

Creates a closing tag

    # File lib/merb-helpers/tag_helpers.rb, line 43
43:       def close_tag(name)
44:         "</#{name}>"
45:       end
open_tag(name, attrs = nil) click to toggle source

Creates the opening tag with attributes for the provided name attrs is a hash where all members will be mapped to key=“value“

Note: This tag will need to be closed

    # File lib/merb-helpers/tag_helpers.rb, line 38
38:       def open_tag(name, attrs = nil)
39:         "<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>"
40:       end
self_closing_tag(name, attrs = nil) click to toggle source

Creates a self closing tag. Like
or

name : the name of the tag to create attrs : a hash where all members will be mapped to key=“value“

    # File lib/merb-helpers/tag_helpers.rb, line 51
51:       def self_closing_tag(name, attrs = nil)
52:         "<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>"
53:       end
tag(name, contents = nil, attrs = {}, &block) click to toggle source

Creates a generic HTML tag. You can invoke it a variety of ways.

  
  tag :div
  # <div></div>
  
  tag :div, 'content'
  # <div>content</div>
  
  tag :div, :class => 'class'
  # <div class="class"></div>
  
  tag :div, 'content', :class => 'class'
  # <div class="class">content</div>
  
  tag :div do
    'content'
  end
  # <div>content</div>
  
  tag :div, :class => 'class' do
    'content'
  end
  # <div class="class">content</div>
    # File lib/merb-helpers/tag_helpers.rb, line 28
28:       def tag(name, contents = nil, attrs = {}, &block)
29:         attrs, contents = contents, nil if contents.is_a?(Hash)
30:         contents = capture(&block) if block_given?
31:         open_tag(name, attrs) + contents.to_s + close_tag(name)
32:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.