Changeset 103
- Timestamp:
- 02/04/2007 11:22:54 (22 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
lib/markaby/builder.rb (modified) (2 diffs)
-
test/test_markaby.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/markaby/builder.rb
r102 r103 27 27 :output_meta_tag => true, 28 28 :auto_validation => true, 29 :tagset => Markaby::XHTMLTransitional 29 :tagset => Markaby::XHTMLTransitional, 30 :root_attributes => { 31 :xmlns => 'http://www.w3.org/1999/xhtml', :'xml:lang' => 'en', :lang => 'en' 32 } 30 33 } 31 34 … … 224 227 # are prepended. Also assumes <tt>:xmlns => "http://www.w3.org/1999/xhtml", 225 228 # :lang => "en"</tt>. 226 def xhtml_transitional( &block)229 def xhtml_transitional(attrs = {}, &block) 227 230 self.tagset = Markaby::XHTMLTransitional 228 xhtml_html( &block)231 xhtml_html(attrs, &block) 229 232 end 230 233 231 234 # Builds an html tag with XHTML 1.0 Strict doctype instead. 232 def xhtml_strict( &block)235 def xhtml_strict(attrs = {}, &block) 233 236 self.tagset = Markaby::XHTMLStrict 234 xhtml_html( &block)237 xhtml_html(attrs, &block) 235 238 end 236 239 237 240 private 238 241 239 def xhtml_html( &block)242 def xhtml_html(attrs = {}, &block) 240 243 instruct! if @output_xml_instruction 241 244 declare!(:DOCTYPE, :html, :PUBLIC, *tagset.doctype) 242 tag!(:html, :xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en", &block)245 tag!(:html, @root_attributes.merge(attrs), &block) 243 246 end 244 247 -
trunk/test/test_markaby.rb
r102 r103 97 97 98 98 def test_full_doc_transitional 99 doc = mab { instruct!;xhtml_transitional { head { title 'OKay' } } }99 doc = mab { xhtml_transitional { head { title 'OKay' } } } 100 100 assert doc =~ /^<\?xml version="1.0" encoding="UTF-8"\?>/ 101 101 assert doc.include?(%{"-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">}) … … 109 109 assert doc.include?(%{<title>OKay</title>}) 110 110 end 111 112 def test_root_attributes_can_be_changed 113 doc = mab { xhtml_strict(:lang => 'fr') { head { title { 'Salut!' } } } } 114 assert doc.include?(%{"-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">}) 115 assert doc.include?(%{<title>Salut!</title>}) 116 assert doc.include?(%{ lang="fr"}) 117 end 111 118 112 119 end