123456789_123456789_123456789_123456789_123456789_

Module: CGI::TagMaker

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/cgi/html.rb

Overview

Base module for HTML-generation mixins.

Provides methods for code generation for tags following the various DTD element types.

Instance Method Summary

Instance Method Details

#nn_element(element, attributes = {})

Generate code for an element with required start and end tags.

- -
[ GitHub ]

  
# File 'lib/cgi/html.rb', line 12

def nn_element(element, attributes = {})
  s = nOE_element(element, attributes)
  if block_given?
    s << yield.to_s
  end
  s << "</#{element.upcase}>"
end

#nn_element_def(attributes = {}, &block)

[ GitHub ]

  
# File 'lib/cgi/html.rb', line 20

def nn_element_def(attributes = {}, &block)
  nn_element(__callee__, attributes, &block)
end

#nO_element(element, attributes = {})

Generate code for an element for which the end (and possibly the start) tag is optional.

O O or - O
[ GitHub ]

  
# File 'lib/cgi/html.rb', line 52

def nO_element(element, attributes = {})
  s = nOE_element(element, attributes)
  if block_given?
    s << yield.to_s
    s << "</#{element.upcase}>"
  end
  s
end

#nO_element_def(attributes = {}, &block)

[ GitHub ]

  
# File 'lib/cgi/html.rb', line 61

def nO_element_def(attributes = {}, &block)
  nO_element(__callee__, attributes, &block)
end

#nOE_element(element, attributes = {})

Generate code for an empty element.

- O EMPTY
[ GitHub ]

  
# File 'lib/cgi/html.rb', line 27

def nOE_element(element, attributes = {})
  attributes={attributes=>nil} if attributes.kind_of?(String)
  s = "<#{element.upcase}".dup
  attributes.each do|name, value|
    next unless value
    s << " "
    s << CGI.escapeHTML(name.to_s)
    if value != true
      s << '="'
      s << CGI.escapeHTML(value.to_s)
      s << '"'
    end
  end
  s << ">"
end

#nOE_element_def(attributes = {}, &block)

[ GitHub ]

  
# File 'lib/cgi/html.rb', line 43

def nOE_element_def(attributes = {}, &block)
  nOE_element(__callee__, attributes, &block)
end