haml 4.0.1.rc.1 → 4.0.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/CHANGELOG.md +7 -1
- data/lib/haml/buffer.rb +7 -6
- data/lib/haml/railtie.rb +1 -0
- data/lib/haml/template.rb +1 -1
- data/lib/haml/version.rb +1 -1
- data/test/helper_test.rb +43 -8
- data/test/templates/_text_area_helper.html.haml +4 -0
- metadata +6 -7
- data/test/gemfiles/Gemfile.rails-3.1.x.lock +0 -100
- data/test/gemfiles/Gemfile.rails-4.0.x.lock +0 -98
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Haml Changelog
|
2
2
|
|
3
|
-
## 4.0.1
|
3
|
+
## 4.0.1
|
4
|
+
|
5
|
+
Released March 21, 2013 ([diff](https://github.com/haml/haml/compare/4.0.0...4.0.1)).
|
4
6
|
|
5
7
|
* Remove Rails 3.2.3+ textarea hack in favor of a more general solution.
|
6
8
|
* Fix some performance regressions.
|
@@ -9,6 +11,10 @@
|
|
9
11
|
(thanks [Alisdair McDiarmid](https://github.com/alisdair))
|
10
12
|
* Fix support for sass-rails 4.0 beta.
|
11
13
|
(thanks [Ryunosuke SATO](https://github.com/tricknotes))
|
14
|
+
* Load "haml/template" in Railtie in order to prevent user options set in a
|
15
|
+
Rails initializer from being overwritten
|
16
|
+
* Don't depend on Rails in haml/template to allow using Haml with ActionView
|
17
|
+
but without Rails itself. (thanks [Hunter Haydel](https://github.com/wedgex))
|
12
18
|
|
13
19
|
## 4.0.0
|
14
20
|
|
data/lib/haml/buffer.rb
CHANGED
@@ -156,7 +156,7 @@ module Haml
|
|
156
156
|
<% end %>
|
157
157
|
|
158
158
|
<% if ugly %>
|
159
|
-
fix_textareas!(result
|
159
|
+
fix_textareas!(result) if toplevel? && result.include?('<textarea')
|
160
160
|
return result
|
161
161
|
<% else %>
|
162
162
|
<% if !(in_tag && preserve_tag && !nuke_inner_whitespace) %>
|
@@ -184,7 +184,7 @@ module Haml
|
|
184
184
|
<% if in_tag && !nuke_inner_whitespace %> result = tabs(tabulation) + result <% end %>
|
185
185
|
end
|
186
186
|
|
187
|
-
fix_textareas!(result
|
187
|
+
fix_textareas!(result) if toplevel? && result.include?('<textarea')
|
188
188
|
|
189
189
|
<% if in_tag && !nuke_inner_whitespace %>
|
190
190
|
result = "\\n\#{result}\\n\#{tabs(tabulation-1)}"
|
@@ -271,14 +271,15 @@ RUBY
|
|
271
271
|
# @param options [Hash] The options hash provided by the Haml::Buffer
|
272
272
|
# @since Haml 4.0.1
|
273
273
|
# @private
|
274
|
-
def fix_textareas!(input
|
274
|
+
def fix_textareas!(input)
|
275
275
|
pattern = /([ ]*)<(textarea)([^>]*)>(\n|
)(.*?)(<\/\2>)/im
|
276
276
|
input.gsub!(pattern) do |s|
|
277
277
|
match = pattern.match(s)
|
278
278
|
content = match[5]
|
279
|
-
|
280
|
-
content.sub!(
|
281
|
-
|
279
|
+
if match[4] == '
'
|
280
|
+
content.sub!(/\A /, ' ')
|
281
|
+
else
|
282
|
+
content.sub!(/\A[ ]*/, '')
|
282
283
|
end
|
283
284
|
"#{match[1]}<#{match[2]}#{match[3]}>\n#{content}</#{match[2]}>"
|
284
285
|
end
|
data/lib/haml/railtie.rb
CHANGED
data/lib/haml/template.rb
CHANGED
data/lib/haml/version.rb
CHANGED
data/test/helper_test.rb
CHANGED
@@ -33,6 +33,7 @@ class HelperTest < MiniTest::Unit::TestCase
|
|
33
33
|
def setup
|
34
34
|
@base = ActionView::Base.new
|
35
35
|
@base.controller = ActionController::Base.new
|
36
|
+
@base.view_paths << File.expand_path("../templates", __FILE__)
|
36
37
|
|
37
38
|
if defined?(ActionController::Response)
|
38
39
|
# This is needed for >=3.0.0
|
@@ -137,24 +138,58 @@ HAML
|
|
137
138
|
render('= content_tag "pre", "Foo bar\n baz"', :action_view))
|
138
139
|
end
|
139
140
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
# Rails >= 3.2.3 adds a newline after opening textarea tags.
|
141
|
+
# Rails >= 3.2.3 adds a newline after opening textarea tags.
|
142
|
+
def self.rails_text_area_helpers_emit_a_newline?
|
144
143
|
major, minor, tiny = ActionPack::VERSION::MAJOR, ActionPack::VERSION::MINOR, ActionPack::VERSION::TINY
|
145
|
-
|
146
|
-
|
144
|
+
major == 4 || ((major == 3) && (minor >= 2) && (tiny >= 3))
|
145
|
+
end
|
146
|
+
|
147
|
+
def text_area_content_regex
|
148
|
+
@text_area_content_regex ||= if self.class.rails_text_area_helpers_emit_a_newline?
|
149
|
+
/<(textarea)[^>]*>\n(.*?)<\/\1>/im
|
150
|
+
else
|
151
|
+
/<(textarea)[^>]*>(.*?)<\/\1>/im
|
147
152
|
end
|
153
|
+
end
|
148
154
|
|
155
|
+
def test_text_area_tag
|
149
156
|
output = render('= text_area_tag "body", "Foo\nBar\n Baz\n Boom"', :action_view)
|
150
|
-
match_data = output.match(
|
157
|
+
match_data = output.match(text_area_content_regex)
|
151
158
|
assert_equal "Foo
Bar
 Baz
 Boom", match_data[2]
|
159
|
+
end
|
152
160
|
|
161
|
+
def test_text_area
|
153
162
|
output = render('= text_area :post, :body', :action_view)
|
154
|
-
match_data = output.match(
|
163
|
+
match_data = output.match(text_area_content_regex)
|
155
164
|
assert_equal "Foo bar
baz", match_data[2]
|
156
165
|
end
|
157
166
|
|
167
|
+
def test_partials_should_not_cause_textareas_to_be_indented
|
168
|
+
# non-indentation of textareas rendered inside partials
|
169
|
+
@base.instance_variable_set('@post', Post.new("Foo", nil, PostErrors.new))
|
170
|
+
output = render(".foo\n .bar\n = render '/text_area_helper'", :action_view)
|
171
|
+
match_data = output.match(text_area_content_regex)
|
172
|
+
assert_equal 'Foo', match_data[2]
|
173
|
+
end
|
174
|
+
|
175
|
+
if rails_text_area_helpers_emit_a_newline?
|
176
|
+
def test_textareas_should_prerve_leading_whitespace
|
177
|
+
# leading whitespace preservation
|
178
|
+
@base.instance_variable_set('@post', Post.new(" Foo", nil, PostErrors.new))
|
179
|
+
output = render(".foo\n = text_area :post, :body", :action_view)
|
180
|
+
match_data = output.match(text_area_content_regex)
|
181
|
+
assert_equal '  Foo', match_data[2]
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_textareas_should_prerve_leading_whitespace_in_partials
|
185
|
+
# leading whitespace in textareas rendered inside partials
|
186
|
+
@base.instance_variable_set('@post', Post.new(" Foo", nil, PostErrors.new))
|
187
|
+
output = render(".foo\n .bar\n = render '/text_area_helper'", :action_view)
|
188
|
+
match_data = output.match(text_area_content_regex)
|
189
|
+
assert_equal '  Foo', match_data[2]
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
158
193
|
def test_capture_haml
|
159
194
|
assert_equal(<<HTML, render(<<HAML))
|
160
195
|
"<p>13</p>\\n"
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 4.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 4.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nathan Weizenbaum
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -144,10 +144,8 @@ files:
|
|
144
144
|
- test/filters_test.rb
|
145
145
|
- test/gemfiles/Gemfile.rails-3.0.x
|
146
146
|
- test/gemfiles/Gemfile.rails-3.1.x
|
147
|
-
- test/gemfiles/Gemfile.rails-3.1.x.lock
|
148
147
|
- test/gemfiles/Gemfile.rails-3.2.x
|
149
148
|
- test/gemfiles/Gemfile.rails-4.0.x
|
150
|
-
- test/gemfiles/Gemfile.rails-4.0.x.lock
|
151
149
|
- test/helper_test.rb
|
152
150
|
- test/markaby/standard.mab
|
153
151
|
- test/mocks/article.rb
|
@@ -179,6 +177,7 @@ files:
|
|
179
177
|
- test/templates/_layout_for_partial.haml
|
180
178
|
- test/templates/_partial.haml
|
181
179
|
- test/templates/_text_area.haml
|
180
|
+
- test/templates/_text_area_helper.html.haml
|
182
181
|
- test/templates/action_view.haml
|
183
182
|
- test/templates/action_view_ugly.haml
|
184
183
|
- test/templates/breakage.haml
|
@@ -252,9 +251,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
251
|
none: false
|
253
252
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
253
|
requirements:
|
255
|
-
- - ! '
|
254
|
+
- - ! '>='
|
256
255
|
- !ruby/object:Gem::Version
|
257
|
-
version:
|
256
|
+
version: '0'
|
258
257
|
none: false
|
259
258
|
requirements: []
|
260
259
|
rubyforge_project:
|
@@ -1,100 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/norman/work/haml
|
3
|
-
specs:
|
4
|
-
haml (4.0.1)
|
5
|
-
tilt
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (3.1.11)
|
11
|
-
actionpack (= 3.1.11)
|
12
|
-
mail (~> 2.3.3)
|
13
|
-
actionpack (3.1.11)
|
14
|
-
activemodel (= 3.1.11)
|
15
|
-
activesupport (= 3.1.11)
|
16
|
-
builder (~> 3.0.0)
|
17
|
-
erubis (~> 2.7.0)
|
18
|
-
i18n (~> 0.6)
|
19
|
-
rack (~> 1.3.6)
|
20
|
-
rack-cache (~> 1.2)
|
21
|
-
rack-mount (~> 0.8.2)
|
22
|
-
rack-test (~> 0.6.1)
|
23
|
-
sprockets (~> 2.0.4)
|
24
|
-
activemodel (3.1.11)
|
25
|
-
activesupport (= 3.1.11)
|
26
|
-
builder (~> 3.0.0)
|
27
|
-
i18n (~> 0.6)
|
28
|
-
activerecord (3.1.11)
|
29
|
-
activemodel (= 3.1.11)
|
30
|
-
activesupport (= 3.1.11)
|
31
|
-
arel (~> 2.2.3)
|
32
|
-
tzinfo (~> 0.3.29)
|
33
|
-
activeresource (3.1.11)
|
34
|
-
activemodel (= 3.1.11)
|
35
|
-
activesupport (= 3.1.11)
|
36
|
-
activesupport (3.1.11)
|
37
|
-
multi_json (~> 1.0)
|
38
|
-
arel (2.2.3)
|
39
|
-
builder (3.0.4)
|
40
|
-
erubis (2.7.0)
|
41
|
-
hike (1.2.1)
|
42
|
-
i18n (0.6.2)
|
43
|
-
json (1.7.7)
|
44
|
-
mail (2.3.3)
|
45
|
-
i18n (>= 0.4.0)
|
46
|
-
mime-types (~> 1.16)
|
47
|
-
treetop (~> 1.4.8)
|
48
|
-
mime-types (1.21)
|
49
|
-
minitest (4.6.1)
|
50
|
-
multi_json (1.6.1)
|
51
|
-
nokogiri (1.5.6)
|
52
|
-
polyglot (0.3.3)
|
53
|
-
rack (1.3.10)
|
54
|
-
rack-cache (1.2)
|
55
|
-
rack (>= 0.4)
|
56
|
-
rack-mount (0.8.3)
|
57
|
-
rack (>= 1.0.0)
|
58
|
-
rack-ssl (1.3.3)
|
59
|
-
rack
|
60
|
-
rack-test (0.6.2)
|
61
|
-
rack (>= 1.0)
|
62
|
-
rails (3.1.11)
|
63
|
-
actionmailer (= 3.1.11)
|
64
|
-
actionpack (= 3.1.11)
|
65
|
-
activerecord (= 3.1.11)
|
66
|
-
activeresource (= 3.1.11)
|
67
|
-
activesupport (= 3.1.11)
|
68
|
-
bundler (~> 1.0)
|
69
|
-
railties (= 3.1.11)
|
70
|
-
railties (3.1.11)
|
71
|
-
actionpack (= 3.1.11)
|
72
|
-
activesupport (= 3.1.11)
|
73
|
-
rack-ssl (~> 1.3.2)
|
74
|
-
rake (>= 0.8.7)
|
75
|
-
rdoc (~> 3.4)
|
76
|
-
thor (~> 0.14.6)
|
77
|
-
rake (10.0.3)
|
78
|
-
rbench (0.2.3)
|
79
|
-
rdoc (3.12.2)
|
80
|
-
json (~> 1.4)
|
81
|
-
sprockets (2.0.4)
|
82
|
-
hike (~> 1.2)
|
83
|
-
rack (~> 1.0)
|
84
|
-
tilt (~> 1.1, != 1.3.0)
|
85
|
-
thor (0.14.6)
|
86
|
-
tilt (1.3.3)
|
87
|
-
treetop (1.4.12)
|
88
|
-
polyglot
|
89
|
-
polyglot (>= 0.3.1)
|
90
|
-
tzinfo (0.3.35)
|
91
|
-
|
92
|
-
PLATFORMS
|
93
|
-
ruby
|
94
|
-
|
95
|
-
DEPENDENCIES
|
96
|
-
haml!
|
97
|
-
minitest
|
98
|
-
nokogiri
|
99
|
-
rails (>= 3.1.0, < 3.2.0)
|
100
|
-
rbench
|
@@ -1,98 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: /Users/norman/work/haml
|
3
|
-
specs:
|
4
|
-
haml (4.0.1)
|
5
|
-
tilt
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (4.0.0.beta1)
|
11
|
-
actionpack (= 4.0.0.beta1)
|
12
|
-
mail (~> 2.5.3)
|
13
|
-
actionpack (4.0.0.beta1)
|
14
|
-
activesupport (= 4.0.0.beta1)
|
15
|
-
builder (~> 3.1.0)
|
16
|
-
erubis (~> 2.7.0)
|
17
|
-
rack (~> 1.5.2)
|
18
|
-
rack-test (~> 0.6.2)
|
19
|
-
activemodel (4.0.0.beta1)
|
20
|
-
activesupport (= 4.0.0.beta1)
|
21
|
-
builder (~> 3.1.0)
|
22
|
-
activerecord (4.0.0.beta1)
|
23
|
-
activemodel (= 4.0.0.beta1)
|
24
|
-
activerecord-deprecated_finders (~> 0.0.3)
|
25
|
-
activesupport (= 4.0.0.beta1)
|
26
|
-
arel (~> 4.0.0.beta1)
|
27
|
-
activerecord-deprecated_finders (0.0.3)
|
28
|
-
activesupport (4.0.0.beta1)
|
29
|
-
i18n (~> 0.6.2)
|
30
|
-
minitest (~> 4.2)
|
31
|
-
multi_json (~> 1.3)
|
32
|
-
thread_safe (~> 0.1)
|
33
|
-
tzinfo (~> 0.3.33)
|
34
|
-
arel (4.0.0.beta1)
|
35
|
-
atomic (1.0.1)
|
36
|
-
builder (3.1.4)
|
37
|
-
erubis (2.7.0)
|
38
|
-
hike (1.2.1)
|
39
|
-
i18n (0.6.2)
|
40
|
-
json (1.7.7)
|
41
|
-
mail (2.5.3)
|
42
|
-
i18n (>= 0.4.0)
|
43
|
-
mime-types (~> 1.16)
|
44
|
-
treetop (~> 1.4.8)
|
45
|
-
mime-types (1.21)
|
46
|
-
minitest (4.6.1)
|
47
|
-
multi_json (1.6.1)
|
48
|
-
nokogiri (1.5.6)
|
49
|
-
polyglot (0.3.3)
|
50
|
-
rack (1.5.2)
|
51
|
-
rack-test (0.6.2)
|
52
|
-
rack (>= 1.0)
|
53
|
-
rails (4.0.0.beta1)
|
54
|
-
actionmailer (= 4.0.0.beta1)
|
55
|
-
actionpack (= 4.0.0.beta1)
|
56
|
-
activerecord (= 4.0.0.beta1)
|
57
|
-
activesupport (= 4.0.0.beta1)
|
58
|
-
bundler (>= 1.3.0, < 2.0)
|
59
|
-
railties (= 4.0.0.beta1)
|
60
|
-
sprockets-rails (~> 2.0.0.rc3)
|
61
|
-
railties (4.0.0.beta1)
|
62
|
-
actionpack (= 4.0.0.beta1)
|
63
|
-
activesupport (= 4.0.0.beta1)
|
64
|
-
rake (>= 0.8.7)
|
65
|
-
rdoc (~> 3.4)
|
66
|
-
thor (>= 0.17.0, < 2.0)
|
67
|
-
rake (10.0.3)
|
68
|
-
rbench (0.2.3)
|
69
|
-
rdoc (3.12.2)
|
70
|
-
json (~> 1.4)
|
71
|
-
sprockets (2.9.0)
|
72
|
-
hike (~> 1.2)
|
73
|
-
multi_json (~> 1.0)
|
74
|
-
rack (~> 1.0)
|
75
|
-
tilt (~> 1.1, != 1.3.0)
|
76
|
-
sprockets-rails (2.0.0.rc3)
|
77
|
-
actionpack (>= 3.0)
|
78
|
-
activesupport (>= 3.0)
|
79
|
-
sprockets (~> 2.8)
|
80
|
-
thor (0.17.0)
|
81
|
-
thread_safe (0.1.0)
|
82
|
-
atomic
|
83
|
-
tilt (1.3.3)
|
84
|
-
treetop (1.4.12)
|
85
|
-
polyglot
|
86
|
-
polyglot (>= 0.3.1)
|
87
|
-
tzinfo (0.3.35)
|
88
|
-
|
89
|
-
PLATFORMS
|
90
|
-
ruby
|
91
|
-
|
92
|
-
DEPENDENCIES
|
93
|
-
bundler (~> 1.3.0)
|
94
|
-
haml!
|
95
|
-
minitest
|
96
|
-
nokogiri
|
97
|
-
rails (~> 4.0.0.beta.1)
|
98
|
-
rbench
|