Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The tag helpers, of which there are only four, are fundamental to the creation of HTML and XML entities. Let’s go through the code that pulls these together:
module Merb module Helpers module Tag 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 def open_tag(name, attrs = nil) "<#{name}#{' '+ attrs.to_html_attributes unless attrs.blank?}>" end # Creates a closing tag def close_tag(name) "</#{name}>" end def self_closing_tag(name, attrs = nil) "<#{name}#{' '+ attrs.to_html_attributes if attrs && !attrs.empty?}/>" end end end end module Merb::GlobalHelpers include Merb::Helpers::Tag end