Changeset 68
- Timestamp:
- 08/10/2006 14:50:25 (2 years ago)
- Location:
- branches/xhtml-careful
- Files:
-
- 3 modified
-
lib/markaby/builder.rb (modified) (1 diff)
-
lib/markaby/cssproxy.rb (modified) (2 diffs)
-
test/test_markaby.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/xhtml-careful/lib/markaby/builder.rb
r67 r68 231 231 232 232 # Builds a image tag. Assumes <tt>:border => '0', :alt => ''</tt>. 233 def img( opts = {})234 tag!(:img, @@default[:image_tag_options].merge(opts))233 def img(*opts, &blk) 234 html_tag(:img, *opts, &blk).merge!(@@default[:image_tag_options]) 235 235 end 236 236 -
branches/xhtml-careful/lib/markaby/cssproxy.rb
r20 r68 13 13 end 14 14 15 # Adds attributes to an element, for internal use only. For example, if you 16 # want to write a wrapper which sets a bunch of default attributes for a certain 17 # tag. Like the default `img' method included with Markaby automatically sets an 18 # empty alt attribute. 19 def merge!(opts) 20 @opts.merge! opts 21 self 22 end 23 15 24 # Adds attributes to an element. Bang methods set the :id attribute. 16 25 # Other methods add to the :class attribute. If a block is supplied, … … 34 43 end 35 44 end 45 46 def to_str 47 @blk.call([[@opts]]).to_s 48 end 49 alias_method :to_s, :to_str 50 36 51 end 37 52 end -
branches/xhtml-careful/test/test_markaby.rb
r67 r68 80 80 assert_equal %{<th colspan="1"></th>}, mab("th(:colspan => 1)") 81 81 assert_equal %{<tbody class="okay"></tbody>}, mab("tbody.okay {}") 82 83 # ticket #19 reported no class attr on img tags 84 assert_equal %{<div><img border="0" class="my_class" alt=""/></div>}, mab("div { img.my_class }") 85 assert_equal %{<div><img border="0" class="my_class" alt="" src="/test.gif"/></div>}, mab("div { img.my_class :src => '/test.gif' }") 82 86 end 83 87