public
Description: Merb Plugins: Even more modules to hook up your Merb installation
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-plugins.git
Fixed bug in tag helper
djwonk (author)
Mon Jul 07 13:41:26 -0700 2008
commit  424178621a6e24d36acda7a8df4d70be1ab1b9ea
tree    92a636a7c51a76d6a9428818480e2019c3b2d020
parent  c24fb2de1305c9c16d1f99fa3b640dca00591387
...
26
27
28
29
 
30
31
32
...
26
27
28
 
29
30
31
32
0
@@ -26,7 +26,7 @@ module Merb
0
       # # <div class="class">content</div>
0
       #
0
       def tag(name, contents = nil, attrs = {}, &block)
0
- attrs = contents if contents.is_a?(Hash)
0
+ attrs, contents = contents, nil if contents.is_a?(Hash)
0
         contents = capture(&block) if block_given?
0
         open_tag(name, attrs) + contents.to_s + close_tag(name)
0
       end
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
0
@@ -1,5 +1,52 @@
0
 require File.dirname(__FILE__) + '/spec_helper'
0
 
0
+describe "tag" do
0
+ it_should_behave_like "FakeBufferConsumer"
0
+
0
+ it %{tag(:div)} do
0
+ tag(:div).should == %{<div></div>}
0
+ end
0
+
0
+ it %{tag(:div, 'content')} do
0
+ tag(:div, 'content').should == %{<div>content</div>}
0
+ end
0
+
0
+ it %{tag(:div, :class => "math")} do
0
+ tag(:div, :class => "math").should == %{<div class="math"></div>}
0
+ end
0
+
0
+ it %{tag(:div, :id => "head")} do
0
+ tag(:div, :id => "head").should == %{<div id="head"></div>}
0
+ end
0
+
0
+ it %{tag(:div, 'content', :class => "math")} do
0
+ tag(:div, 'content', :class => "math").should ==
0
+ %{<div class="math">content</div>}
0
+ end
0
+
0
+ it %{tag(:div) { 'content' }} do
0
+ o = tag(:div) do
0
+ _buffer << 'content'
0
+ end
0
+ o.should == %{<div>content</div>}
0
+ end
0
+
0
+ it %{tag(:div, :class => "math") { 'content' }} do
0
+ o = tag(:div, :class => "math") do
0
+ _buffer << 'content'
0
+ end
0
+ o.should == %{<div class="math">content</div>}
0
+ end
0
+
0
+ it %{tag(:div, :id => "head") { 'content' }} do
0
+ o = tag(:div, :id => "head") do
0
+ _buffer << 'content'
0
+ end
0
+ o.should == %{<div id="head">content</div>}
0
+ end
0
+
0
+end
0
+
0
 describe "error_messages_for" do
0
   before :each do
0
     @obj = Object.new

Comments

    No one has commented yet.