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
-
#nn_element(element, attributes = {})
Generate code for an element with required start and end tags.
- #nn_element_def(attributes = {}, &block)
-
#nO_element(element, attributes = {})
Generate code for an element for which the end (and possibly the start) tag is optional.
- #nO_element_def(attributes = {}, &block)
-
#nOE_element(element, attributes = {})
Generate code for an empty element.
- #nOE_element_def(attributes = {}, &block)
Instance Method Details
#nn_element(element, attributes = {})
Generate code for an element with required start and end tags.
- -
# 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
# 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
# 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