haml-edge 2.1.18 → 2.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/EDGE_GEM_VERSION +1 -1
- data/VERSION +1 -1
- data/lib/haml/buffer.rb +15 -0
- data/lib/haml/helpers.rb +3 -0
- data/lib/haml/precompiler.rb +1 -1
- data/lib/haml/template/plugin.rb +2 -1
- data/test/haml/helper_test.rb +22 -1
- data/test/haml/template_test.rb +4 -0
- metadata +2 -2
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.19
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.19
|
data/lib/haml/buffer.rb
CHANGED
@@ -19,6 +19,10 @@ module Haml
|
|
19
19
|
# It's nil at the top level (see #toplevel?).
|
20
20
|
attr_accessor :upper
|
21
21
|
|
22
|
+
# nil if there's no capture_haml block running,
|
23
|
+
# and the position at which it's beginning the capture if there is one.
|
24
|
+
attr_accessor :capture_position
|
25
|
+
|
22
26
|
# See #active?
|
23
27
|
attr_writer :active
|
24
28
|
|
@@ -193,6 +197,17 @@ RUBY
|
|
193
197
|
@real_tabs += 1 unless self_closing || nuke_inner_whitespace
|
194
198
|
end
|
195
199
|
|
200
|
+
# Remove the whitespace from the right side of the buffer string.
|
201
|
+
# Doesn't do anything if we're at the beginning of a capture_haml block.
|
202
|
+
def rstrip!
|
203
|
+
if capture_position.nil?
|
204
|
+
buffer.rstrip!
|
205
|
+
return
|
206
|
+
end
|
207
|
+
|
208
|
+
buffer << buffer.slice!(capture_position..-1).rstrip
|
209
|
+
end
|
210
|
+
|
196
211
|
def self.merge_attrs(to, from)
|
197
212
|
if to['id'] && from['id']
|
198
213
|
to['id'] << '_' << from.delete('id')
|
data/lib/haml/helpers.rb
CHANGED
@@ -275,6 +275,7 @@ module Haml
|
|
275
275
|
with_haml_buffer(buffer) do
|
276
276
|
position = haml_buffer.buffer.length
|
277
277
|
|
278
|
+
haml_buffer.capture_position = position
|
278
279
|
block.call(*args)
|
279
280
|
|
280
281
|
captured = haml_buffer.buffer.slice!(position..-1).split(/^/)
|
@@ -290,6 +291,8 @@ module Haml
|
|
290
291
|
line[min_tabs..-1]
|
291
292
|
end.join
|
292
293
|
end
|
294
|
+
ensure
|
295
|
+
haml_buffer.capture_position = nil
|
293
296
|
end
|
294
297
|
|
295
298
|
def puts(*args) # :nodoc:
|
data/lib/haml/precompiler.rb
CHANGED
data/lib/haml/template/plugin.rb
CHANGED
@@ -12,7 +12,8 @@ module Haml
|
|
12
12
|
# template is a template object in Rails >=2.1.0,
|
13
13
|
# a source string previously
|
14
14
|
if template.respond_to? :source
|
15
|
-
|
15
|
+
# Template has a generic identifier in Rails >=3.0.0
|
16
|
+
options[:filename] = template.respond_to?(:identifier) ? template.identifier : template.filename
|
16
17
|
source = template.source
|
17
18
|
else
|
18
19
|
source = template
|
data/test/haml/helper_test.rb
CHANGED
@@ -14,6 +14,12 @@ class HelperTest < Test::Unit::TestCase
|
|
14
14
|
def setup
|
15
15
|
@base = ActionView::Base.new
|
16
16
|
@base.controller = ActionController::Base.new
|
17
|
+
|
18
|
+
if defined?(ActionController::Response)
|
19
|
+
# This is needed for >=3.0.0
|
20
|
+
@base.controller.response = ActionController::Response.new
|
21
|
+
end
|
22
|
+
|
17
23
|
@base.instance_variable_set('@post', Post.new("Foo bar\nbaz"))
|
18
24
|
end
|
19
25
|
|
@@ -61,7 +67,7 @@ class HelperTest < Test::Unit::TestCase
|
|
61
67
|
|
62
68
|
begin
|
63
69
|
ActionView::Base.new.render(:inline => "<%= flatten('Foo\\nBar') %>")
|
64
|
-
rescue NoMethodError
|
70
|
+
rescue NoMethodError, ActionView::TemplateError
|
65
71
|
proper_behavior = true
|
66
72
|
end
|
67
73
|
assert(proper_behavior)
|
@@ -229,5 +235,20 @@ HAML
|
|
229
235
|
def test_random_class_includes_tag_helper
|
230
236
|
assert_equal "<p>some tag content</p>", ActsLikeTag.new.to_s
|
231
237
|
end
|
238
|
+
|
239
|
+
def test_capture_with_nuke_outer
|
240
|
+
assert_equal "<div></div>\n*<div>hi there!</div>\n", render(<<HAML)
|
241
|
+
%div
|
242
|
+
= precede("*") do
|
243
|
+
%div> hi there!
|
244
|
+
HAML
|
245
|
+
|
246
|
+
assert_equal "<div></div>\n*<div>hi there!</div>\n", render(<<HAML)
|
247
|
+
%div
|
248
|
+
= precede("*") do
|
249
|
+
= " "
|
250
|
+
%div> hi there!
|
251
|
+
HAML
|
252
|
+
end
|
232
253
|
end
|
233
254
|
|
data/test/haml/template_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml-edge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Weizenbaum
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-03 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|