public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Version 1.0.5 released.


git-svn-id: svn://hamptoncatlin.com/haml/tags/stable@306 
7063305b-7217-0410-af8c-cdc13e5119b9
nex3 (author)
Thu Jan 25 20:30:38 -0800 2007
commit  9d73e9259079fc7bf7bffc83507ba226581c3c3f
tree    1d6423e99fb512c37258eddcec699935de77700b
parent  e155f8c5d7d18d65daa34fd83af07b7891bd3d25
...
1
 
...
 
1
0
@@ -1 +1 @@
0
-1.0.4
0
+1.0.5
...
214
215
216
 
 
 
 
 
 
 
 
 
217
218
219
220
 
 
 
 
 
 
...
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
0
@@ -214,7 +214,22 @@ module Haml
0
       end
0
       result.to_s
0
     end
0
+
0
+ # Returns whether or not the current template is a Haml template.
0
+ #
0
+ # This function, unlike other Haml::Helpers functions,
0
+ # also works in other ActionView templates,
0
+ # where it will always return false.
0
+ def is_haml?
0
+ @haml_stack ? @haml_stack.size > 0 : false
0
+ end
0
     
0
     include ActionViewMods if self.const_defined? "ActionViewMods"
0
   end
0
 end
0
+
0
+class ActionView::Base # :nodoc:
0
+ def is_haml?
0
+ false
0
+ end
0
+end
...
32
33
34
35
 
 
 
 
 
36
37
38
39
 
40
41
42
...
32
33
34
 
35
36
37
38
39
40
41
42
 
43
44
45
46
0
@@ -32,11 +32,15 @@ if action_view_included
0
         end
0
         
0
         def concat(string, binding = nil) # :nodoc:
0
- buffer.buffer.concat(string)
0
+ if is_haml?
0
+ buffer.buffer.concat(string)
0
+ else
0
+ old_concat(string, binding)
0
+ end
0
         end
0
         
0
         def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) # :nodoc:
0
- if block_given?
0
+ if block_given? && is_haml?
0
             oldproc = proc
0
             proc = bind_proc do |*args|
0
               concat "\n"
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@
0
   </head>
0
   <body>
0
     <!-- You're In my house now! -->
0
- <div class='header'>
0
+Foo <div class='header'>
0
       Yes, ladies and gentileman. He is just that egotistical.
0
       Fantastic! This should be multi-line output
0
       The question is if this would translate! Ahah!
...
6
7
8
 
9
10
11
...
6
7
8
9
10
11
12
0
@@ -6,6 +6,7 @@
0
   </head>
0
   <body>
0
     <!-- You're In my house now! -->
0
+ <% concat "Foo", Proc.new {} %>
0
     <div class='header'>
0
       Yes, ladies and gentileman. He is just that egotistical.
0
       Fantastic! This should be multi-line output
...
80
81
82
 
 
 
 
 
 
 
 
83
84
85
...
80
81
82
83
84
85
86
87
88
89
90
91
92
93
0
@@ -80,6 +80,14 @@ class TemplateTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_rhtml_still_renders
0
+ # Make sure it renders normally
0
+ res = @base.render("../rhtml/standard")
0
+ assert !(res.nil? || res.empty?)
0
+
0
+ # Register Haml stuff in @base...
0
+ @base.render("standard")
0
+
0
+ # Does it still render?
0
     res = @base.render("../rhtml/standard")
0
     assert !(res.nil? || res.empty?)
0
   end
...
5
6
7
 
8
9
10
...
5
6
7
8
9
10
11
0
@@ -5,6 +5,7 @@
0
     %meta{"http-equiv" => "Content-Type", :content => "text/html; charset=utf-8"}/
0
   %body
0
     / You're In my house now!
0
+ - concat "Foo"
0
     .header
0
       Yes, ladies and gentileman. He is just that egotistical.
0
       Fantastic! This should be multi-line output

Comments

    No one has commented yet.