haml 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of haml might be problematic. Click here for more details.

data/README CHANGED
@@ -47,7 +47,7 @@ a tag without a name defaults to a div. So
47
47
 
48
48
  becomes
49
49
 
50
- <div id='foo'>Hello!</foo>
50
+ <div id='foo'>Hello!</div>
51
51
 
52
52
  Haml uses indentation
53
53
  to bring the individual elements to represent the HTML structure.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.0
1
+ 1.5.1
@@ -129,13 +129,6 @@ END
129
129
  }
130
130
  }
131
131
 
132
- unless @options[:suppress_eval]
133
- @options[:filters].merge!({
134
- 'erb' => ERB,
135
- 'ruby' => Haml::Filters::Ruby
136
- })
137
- end
138
-
139
132
  if !NOT_LOADED.include? 'redcloth'
140
133
  @options[:filters].merge!({
141
134
  'redcloth' => RedCloth,
@@ -149,6 +142,14 @@ END
149
142
 
150
143
  @options.rec_merge! options
151
144
 
145
+ unless @options[:suppress_eval]
146
+ @options[:filters].merge!({
147
+ 'erb' => ERB,
148
+ 'ruby' => Haml::Filters::Ruby
149
+ })
150
+ end
151
+ @options[:filters].rec_merge! options[:filters] if options[:filters]
152
+
152
153
  @precompiled = @options[:precompiled]
153
154
 
154
155
  @template = template.strip #String
@@ -309,8 +310,9 @@ END
309
310
  when SILENT_SCRIPT
310
311
  sub_line = line[1..-1]
311
312
  unless sub_line[0] == SILENT_COMMENT
312
- push_silent(sub_line, true)
313
- if @block_opened && !mid_block_keyword?(line)
313
+ mbk = mid_block_keyword?(line)
314
+ push_silent(sub_line, !mbk)
315
+ if (@block_opened && !mbk) || line[1..-1].split(' ', 2)[0] == "case"
314
316
  push_and_tabulate([:script])
315
317
  end
316
318
  end
@@ -589,7 +591,7 @@ END
589
591
  warn(FLAT_WARNING) if flattened && !defined?(Test::Unit)
590
592
 
591
593
  value_exists = !value.empty?
592
- attributes_hash = "nil" unless attributes_hash
594
+ attributes_hash = "nil" if attributes_hash.nil? || @options[:suppress_eval]
593
595
  object_ref = "nil" unless object_ref
594
596
 
595
597
  if @block_opened
@@ -8,12 +8,12 @@ module Haml
8
8
  module Helpers
9
9
  self.extend self
10
10
 
11
- @@action_view = false
11
+ @@action_view_defined = defined?(ActionView)
12
12
  @@force_no_action_view = false
13
13
 
14
14
  # Returns whether or not ActionView is installed on the system.
15
15
  def self.action_view?
16
- @@action_view
16
+ @@action_view_defined
17
17
  end
18
18
 
19
19
  # Isolates the whitespace-sensitive tags in the string and uses preserve
@@ -186,11 +186,6 @@ module Haml
186
186
  end
187
187
 
188
188
  private
189
-
190
- # Sets whether or not ActionView is installed on the system.
191
- def self.action_view(value) # :nodoc:
192
- @@action_view = value
193
- end
194
189
 
195
190
  # Gets a reference to the current Haml::Buffer object.
196
191
  def buffer
@@ -226,6 +221,7 @@ module Haml
226
221
  end
227
222
  result.to_s
228
223
  end
224
+ alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
229
225
 
230
226
  # Returns whether or not the current template is a Haml template.
231
227
  #
@@ -235,8 +231,6 @@ module Haml
235
231
  def is_haml?
236
232
  @haml_stack ? @haml_stack.size > 0 : false
237
233
  end
238
-
239
- include ActionViewMods if self.const_defined? "ActionViewMods"
240
234
  end
241
235
  end
242
236
 
@@ -9,42 +9,24 @@ rescue LoadError
9
9
  end
10
10
 
11
11
  if action_view_included
12
- class ActionView::Base
13
- alias_method :old_concat, :concat unless instance_methods.include? "old_concat"
14
- alias_method :old_form_tag, :form_tag unless instance_methods.include? "old_form_tag"
15
-
16
- alias_method :old_form_for, :form_for unless instance_methods.include? "old_form_for"
17
- end
18
-
19
- module Haml
12
+ module ActionView
13
+ # This overrides various helpers in ActionView
14
+ # to make them work more effectively with Haml.
20
15
  module Helpers
21
- # This module overrides various helpers in ActionView
22
- # to make them work more effectively with Haml.
23
- # It also defines several helper methods,
24
- # available from a Haml template,
25
- # which are only useful within the context of ActionView.
26
- # It's not available unless ActionView is installed.
27
- #
28
- #--
29
- # Methods in this module should be nodoc'd.
30
- #++
31
- module ActionViewMods
32
- def self.included(othermod) # :nodoc:
33
- othermod.class_eval do
34
- action_view(true)
35
- alias_method :capture_erb_with_buffer, :capture_haml_with_buffer
36
- end
37
- end
38
-
39
- def concat(string, binding = nil) # :nodoc:
16
+ # :stopdoc:
17
+ module TextHelper
18
+ def concat_with_haml(string, binding = nil)
40
19
  if is_haml?
41
20
  buffer.buffer.concat(string)
42
21
  else
43
- old_concat(string, binding)
22
+ concat_without_haml(string, binding)
44
23
  end
45
24
  end
46
-
47
- def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &proc) # :nodoc:
25
+ alias_method_chain :concat, :haml
26
+ end
27
+
28
+ module FormTagHelper
29
+ def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
48
30
  if block_given? && is_haml?
49
31
  oldproc = proc
50
32
  proc = bind_proc do |*args|
@@ -54,29 +36,33 @@ if action_view_included
54
36
  tab_down
55
37
  end
56
38
  end
57
- res = old_form_tag(url_for_options, options, *parameters_for_url, &proc) + "\n"
39
+ res = form_tag_without_haml(url_for_options, options, *parameters_for_url, &proc) + "\n"
58
40
  concat "\n" if block_given? && is_haml?
59
41
  res
60
42
  end
61
-
62
- def form_for(object_name, *args, &proc) # :nodoc:
43
+ alias_method_chain :form_tag, :haml
44
+ end
45
+
46
+ module FormHelper
47
+ def form_for_with_haml(object_name, *args, &proc)
63
48
  if block_given? && is_haml?
64
49
  oldproc = proc
65
50
  proc = bind_proc do |*args|
66
51
  tab_up
67
52
  oldproc.call(*args)
68
53
  tab_down
69
- end
54
+ end
70
55
  end
71
- old_form_for(object_name, *args, &proc)
56
+ form_for_without_haml(object_name, *args, &proc)
72
57
  concat "\n" if block_given? && is_haml?
73
58
  end
74
-
75
- def generate_content_class_names
76
- controller.controller_name + " " + controller.action_name
77
- end
59
+ alias_method_chain :form_for, :haml
60
+ end
61
+
62
+ def generate_content_class_names
63
+ controller.controller_name + " " + controller.action_name
78
64
  end
65
+ # :startdoc:
79
66
  end
80
67
  end
81
68
  end
82
-
@@ -392,7 +392,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
392
392
  # Defaults to false.
393
393
  # Only has meaning within Ruby on Rails.
394
394
  #
395
- # [<tt>:always_update</tt>] Whether a Sass template should be checked for updates every
395
+ # [<tt>:always_check</tt>] Whether a Sass template should be checked for updates every
396
396
  # time a controller is accessed,
397
397
  # as opposed to only when the Rails server starts.
398
398
  # If a Sass template has been updated,
@@ -57,6 +57,15 @@ class EngineTest < Test::Unit::TestCase
57
57
 
58
58
  def test_stop_eval
59
59
  assert_equal("", render("= 'Hello'", :suppress_eval => true))
60
+ assert_equal("<div id='foo' />\n", render("#foo{:yes => 'no'}/", :suppress_eval => true))
61
+
62
+ begin
63
+ assert_equal("", render(":ruby\n puts 'hello'", :suppress_eval => true))
64
+ rescue Haml::HamlError => err
65
+ caught = true
66
+ assert_equal('Filter "ruby" is not defined!', err.message)
67
+ end
68
+ assert(caught, "Rendering a ruby filter without evaluating didn't throw an error!")
60
69
  end
61
70
 
62
71
  def test_attr_wrapper
@@ -62,9 +62,9 @@ class HelperTest < Test::Unit::TestCase
62
62
 
63
63
  begin
64
64
  ActionView::Base.new.render(:inline => "<%= concat('foo') %>")
65
- rescue ArgumentError
65
+ rescue ArgumentError, NameError
66
66
  proper_behavior = true
67
- end
67
+ end
68
68
  assert(proper_behavior)
69
69
  end
70
70
 
@@ -41,3 +41,5 @@ stuff followed by whitespace
41
41
  Woah a period.
42
42
  <![endif]-->
43
43
  testtest
44
+ <foo />
45
+ <foo />
@@ -38,4 +38,14 @@
38
38
  /[if gte IE5.2]
39
39
  Woah a period.
40
40
  = "test" |
41
- "test" |
41
+ "test" |
42
+ - case :foo
43
+ - when :bar
44
+ %bar/
45
+ - when :foo
46
+ %foo/
47
+ - case :foo
48
+ - when :bar
49
+ %bar/
50
+ - when :foo
51
+ %foo/
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: haml
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.5.0
7
- date: 2007-03-06 00:00:00 -08:00
6
+ version: 1.5.1
7
+ date: 2007-03-31 00:00:00 -07:00
8
8
  summary: An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.
9
9
  require_paths:
10
10
  - lib