Changeset 67
- Timestamp:
- 08/10/2006 14:15:33 (2 years ago)
- Location:
- branches/xhtml-careful
- Files:
-
- 2 modified
-
lib/markaby/builder.rb (modified) (4 diffs)
-
test/test_markaby.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/xhtml-careful/lib/markaby/builder.rb
r65 r67 55 55 @streams = [[]] 56 56 @assigns = assigns 57 @elements = {} 57 58 58 59 @@default.each do |k, v| … … 141 142 # the arguments are the same as the tags implemented via method_missing. 142 143 def tag!(tag, *args, &block) 144 ele_id = nil 143 145 if @auto_validation and @tagset 144 146 if !@tagset.tagset.has_key?(tag) … … 147 149 attrs = args.last.to_hash 148 150 attrs.each do |k, v| 149 unless k =~ /:/ or @tagset.tagset[tag].include? k.to_s.downcase.intern 151 atname = k.to_s.downcase.intern 152 unless k =~ /:/ or @tagset.tagset[tag].include? atname 150 153 raise InvalidXhtmlError, "no attribute `#{k}' on #{tag} elements" 154 end 155 if atname == :id 156 ele_id = v.to_s 157 if @elements.has_key? ele_id 158 raise InvalidXhtmlError, "id `#{ele_id}' already used (id's must be unique)." 159 end 151 160 end 152 161 end … … 157 166 block = proc { text(str) } 158 167 end 159 fragment { @builder.method_missing(tag, *args, &block) } 168 169 f = fragment { @builder.method_missing(tag, *args, &block) } 170 @elements[ele_id] = f if ele_id 171 f 160 172 end 161 173 -
branches/xhtml-careful/test/test_markaby.rb
r66 r67 86 86 assert_exception %{div(:styl => 'ok') {}}, Markaby::InvalidXhtmlError, "no attribute `styl' on div elements" 87 87 end 88 89 def test_unique_ids 90 assert_exception %{html { div.one! {}; div.one! {} }}, Markaby::InvalidXhtmlError, "id `one' already used (id's must be unique)." 91 assert_equal "<div id=\"one\"></div>", mab(%{div.one! {}}) 92 end 93 88 94 end