public
Description: Merb More: The Full Stack. Take what you need; leave what you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-more.git
Search Repo:
Fix merb-builder, thanks atmpos
ezmobius (author)
Fri May 02 17:30:58 -0700 2008
commit  60fe88514673c438e5cd793e536788761105c8ac
tree    aeb3423e5359fbd9cc892644f16415cbd3bb13f6
parent  c99e18b072be2aab475488685b5ebb9944fa97ed
...
28
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
...
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
53
54
55
56
57
58
59
60
61
62
63
0
@@ -28,7 +28,36 @@ module Merb::Template
0
       name
0
     end
0
   
0
- module Mixin; end
0
+ module Mixin
0
+ def _builder_buffer(the_binding)
0
+ @_buffer = eval("xml", the_binding, __FILE__, __LINE__)
0
+ end
0
+ # ==== Parameters
0
+ # *args:: Arguments to pass to the block.
0
+ # &block:: The template block to call.
0
+ #
0
+ # ==== Returns
0
+ # String:: The output of the block.
0
+ #
0
+ # ==== Examples
0
+ # Capture being used in a .html.erb page:
0
+ #
0
+ # @foo = capture do
0
+ # xml.instruct!
0
+ # xml.foo do
0
+ # xml.bar "baz"
0
+ # end
0
+ # xml.target!
0
+ # end
0
+ def capture_builder(*args, &block)
0
+ block.call(*args)
0
+ end
0
+
0
+ def concat_builder(string, binding)
0
+ _builder_buffer(binding) << string
0
+ end
0
+
0
+ end
0
     Merb::Template.register_extensions(self, %w[builder])
0
   end
0
 end
...
33
34
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
0
@@ -33,4 +33,24 @@ describe "Builder" do
0
     end
0
     c.body.should == xml.target!
0
   end
0
+
0
+ it "should capture_builder properly" do
0
+ c = dispatch_to(CaptureBuilder, :index, :format => "xml")
0
+ xml = ::Builder::XmlMarkup.new :indent => 4
0
+ xml.instruct!
0
+ xml.comment! "I would not say such things if I were you"
0
+ xml.node 'Capture'
0
+
0
+ c.body.should == xml.target!
0
+ end
0
+
0
+ it "should concat_builder properly" do
0
+ c = dispatch_to(ConcatBuilder, :index, :format => "xml")
0
+ xml = ::Builder::XmlMarkup.new :indent => 4
0
+ xml.instruct!
0
+ xml.node 'Concat'
0
+
0
+ c.body.should == xml.target!.chomp
0
+ end
0
+
0
 end
...
20
21
22
 
 
 
 
 
 
 
 
 
23
24
...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
0
@@ -20,4 +20,13 @@ class PartialIvars < BuilderController
0
 end
0
 
0
 class CaptureBuilder < BuilderController
0
+end
0
+
0
+module Merb::ConcatBuilderHelper
0
+ def concatter(&blk)
0
+ concat("<node>Concat</node>", blk.binding)
0
+ end
0
+end
0
+
0
+class ConcatBuilder < BuilderController
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.