module CGI::TagMaker
def nOE_element(element, attributes = {})
Generate code for an empty element.
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
def nOE_element_def(attributes = {}, &block)
def nOE_element_def(attributes = {}, &block) nOE_element(__callee__, attributes, &block) end
def nO_element(element, attributes = {})
start) tag is optional.
Generate code for an element for which the end (and possibly the
def nO_element(element, attributes = {}) s = nOE_element(element, attributes) if block_given? s << yield.to_s s << "</#{element.upcase}>" end s end
def nO_element_def(attributes = {}, &block)
def nO_element_def(attributes = {}, &block) nO_element(__callee__, attributes, &block) end
def nn_element(element, attributes = {})
Generate code for an element with required start and end tags.
def nn_element(element, attributes = {}) s = nOE_element(element, attributes) if block_given? s << yield.to_s end s << "</#{element.upcase}>" end
def nn_element_def(attributes = {}, &block)
def nn_element_def(attributes = {}, &block) nn_element(__callee__, attributes, &block) end