Class: MasterView::TemplateProcessing::SimpleRenderHandler
- Inherits:
-
Object
- Object
- MasterView::TemplateProcessing::SimpleRenderHandler
- Defined in:
- lib/masterview/parser.rb
Overview
Default renderer for document elements, invoked after any other directives on a document element have been processed.
Unless preempted by a previously invoked directive, the default rendering is to copy the element content to the output.
Instance Method Summary collapse
- #cdata(dcs) ⇒ Object
- #characters(dcs) ⇒ Object
- #comment(dcs) ⇒ Object
- #description ⇒ Object
- #etag(dcs) ⇒ Object
- #stag(dcs) ⇒ Object
Instance Method Details
#cdata(dcs) ⇒ Object
168 169 170 171 |
# File 'lib/masterview/parser.rb', line 168 def cdata(dcs) context = dcs.context [] << '<![CDATA[' << context[:content_part] << ']]>' end |
#characters(dcs) ⇒ Object
158 159 160 161 |
# File 'lib/masterview/parser.rb', line 158 def characters(dcs) context = dcs.context [] << context[:content_part] end |
#comment(dcs) ⇒ Object
163 164 165 166 |
# File 'lib/masterview/parser.rb', line 163 def comment(dcs) context = dcs.context [] << '<!-- ' << context[:content_part] << ' -->' end |
#description ⇒ Object
132 133 134 |
# File 'lib/masterview/parser.rb', line 132 def description 'SimpleRenderHandler is the default renderer for nodes, it should be invoked as the last directive and will output node normally' end |
#etag(dcs) ⇒ Object
173 174 175 176 |
# File 'lib/masterview/parser.rb', line 173 def etag(dcs) context = dcs.context [] << '</' << "#{context[:tag].tag_name.to_s}>" #must output </ as separate string so simplify_empty_elements can find it end |
#stag(dcs) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/masterview/parser.rb', line 136 def stag(dcs) context = dcs.context ret = [] # NOTE: although strictly speaking attribute order is not significant # in XML, in practice some template authors may have a preferred style # for the order in which they write attribute markup in their templates. # In such cases, it would be nice to be able to support a config option # to preserve original attribute order, rather than the forced sort-by-name # as done here. However, would need to get into the parser # and have it use a facets Dictionary rather than standard {} Hash # when collecting element attributes so we have order available at this point. # Hook: rexml/parsers/baseparser.rb - pull method, :start_element event # http://facets.rubyforge.org/api/more/classes/Dictionary.html # [DJL 18-Jul-2006] ret << "<#{context[:tag].tag_name.to_s}" # allow for symbol tag_name sorted_attributes = context[:tag].attributes.sort { |a,b| a[0].to_s <=> b[0].to_s } #allow for symbols using to_s sorted_attributes.each do |name, value| ret << " #{name.to_s}=\"#{value}\"" # allow for key to by symbol end ret << '>' #must output as separate string so simplify_empty_elements can find it end |