haml-edge 3.1.19 → 3.1.20
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/filters.rb +7 -1
- data/lib/haml/helpers/action_view_mods.rb +37 -0
- data/lib/haml/template.rb +22 -0
- data/lib/haml/util.rb +19 -2
- metadata +1 -1
data/EDGE_GEM_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.20
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.20
|
data/lib/haml/filters.rb
CHANGED
@@ -308,10 +308,16 @@ END
|
|
308
308
|
# @see Base#compile
|
309
309
|
def compile(precompiler, text)
|
310
310
|
return if precompiler.options[:suppress_eval]
|
311
|
-
src =
|
311
|
+
src = RealERB.new(text).src.sub(/^#coding:.*?\n/, '').
|
312
312
|
sub(/^_erbout = '';/, "")
|
313
313
|
precompiler.send(:push_silent, src)
|
314
314
|
end
|
315
|
+
|
316
|
+
# This is a dummy ERB subclass
|
317
|
+
# that's used to work around Rails 2.3.6's
|
318
|
+
# incompatible monkeypatches of ERB.
|
319
|
+
# It's modified in `haml/template.rb` if need be.
|
320
|
+
class RealERB < ::ERB; end
|
315
321
|
end
|
316
322
|
|
317
323
|
# Parses the filtered text with [Textile](http://www.textism.com/tools/textile).
|
@@ -97,6 +97,22 @@ module ActionView
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
# For some reason, Rails 2.3.6 uses #safe_concat in #capture
|
101
|
+
# even when XSS support is disabled.
|
102
|
+
if Haml::Util.ap_2_3_6?
|
103
|
+
module TextHelper
|
104
|
+
def concat_with_haml(string, binding = nil)
|
105
|
+
if is_haml?
|
106
|
+
haml_buffer.buffer.concat(string)
|
107
|
+
else
|
108
|
+
concat_without_haml(string, binding)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
alias_method :concat_without_haml, :concat
|
112
|
+
alias_method :concat, :concat_with_haml
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
100
116
|
module TagHelper
|
101
117
|
def content_tag_with_haml(name, *args, &block)
|
102
118
|
return content_tag_without_haml(name, *args, &block) unless is_haml?
|
@@ -238,3 +254,24 @@ module ActionView
|
|
238
254
|
end
|
239
255
|
end
|
240
256
|
end
|
257
|
+
|
258
|
+
# Rails 2.3.6 uses #safe_concat in #fragment_for
|
259
|
+
# rather than using #concat with an #html_safe string.
|
260
|
+
# This fixes that issue.
|
261
|
+
if Haml::Util.ap_2_3_6?
|
262
|
+
module ActionController::Caching::Fragments
|
263
|
+
def fragment_for(buffer, name = {}, options = nil, &block) #:nodoc:
|
264
|
+
if perform_caching
|
265
|
+
if cache = read_fragment(name, options)
|
266
|
+
buffer.concat(cache.html_safe)
|
267
|
+
else
|
268
|
+
pos = buffer.length
|
269
|
+
block.call
|
270
|
+
write_fragment(name, buffer[pos..-1], options)
|
271
|
+
end
|
272
|
+
else
|
273
|
+
block.call
|
274
|
+
end
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
data/lib/haml/template.rb
CHANGED
@@ -64,6 +64,28 @@ else
|
|
64
64
|
Haml::Template.try_enabling_xss_integration
|
65
65
|
end
|
66
66
|
|
67
|
+
# Rails 2.3.6 monkeypatches ERB in incompatible ways.
|
68
|
+
# We fix our own subclass of ERB here so the Haml ERB filter
|
69
|
+
# will continue to work.
|
70
|
+
if Haml::Util.ap_2_3_6?
|
71
|
+
class Haml::Filters::ERB::RealERB
|
72
|
+
def set_eoutvar(compiler, eoutvar = '_erbout')
|
73
|
+
compiler.put_cmd = "#{eoutvar}.concat"
|
74
|
+
compiler.insert_cmd = "#{eoutvar}.concat"
|
75
|
+
|
76
|
+
cmd = []
|
77
|
+
cmd.push "#{eoutvar} = ''"
|
78
|
+
|
79
|
+
compiler.pre_cmd = cmd
|
80
|
+
|
81
|
+
cmd = []
|
82
|
+
cmd.push(eoutvar)
|
83
|
+
|
84
|
+
compiler.post_cmd = cmd
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
67
89
|
if Haml::Util.rails_root
|
68
90
|
# Update init.rb to the current version
|
69
91
|
# if it's out of date.
|
data/lib/haml/util.rb
CHANGED
@@ -324,6 +324,20 @@ module Haml
|
|
324
324
|
$1.to_i >= 3))
|
325
325
|
end
|
326
326
|
|
327
|
+
# Returns whether this environment is using ActionPack
|
328
|
+
# version 2.3.6 (or greater, up until 3.0.0).
|
329
|
+
#
|
330
|
+
# @return [Boolean]
|
331
|
+
def ap_2_3_6?
|
332
|
+
# Hopefully Rails 2.3.7 will fix the issues that this method hacks around,
|
333
|
+
# but for now we'll assume it won't
|
334
|
+
require 'action_pack'
|
335
|
+
defined?(ActionPack::VERSION::MAJOR) &&
|
336
|
+
ActionPack::VERSION::MAJOR == 2 &&
|
337
|
+
ActionPack::VERSION::MINOR == 3 &&
|
338
|
+
ActionPack::VERSION::TINY >= 6
|
339
|
+
end
|
340
|
+
|
327
341
|
# Returns an ActionView::Template* class.
|
328
342
|
# In pre-3.0 versions of Rails, most of these classes
|
329
343
|
# were of the form `ActionView::TemplateFoo`,
|
@@ -374,8 +388,11 @@ module Haml
|
|
374
388
|
#
|
375
389
|
# @return [Class]
|
376
390
|
def rails_safe_buffer_class
|
377
|
-
|
378
|
-
|
391
|
+
# It's important that we check ActiveSupport first,
|
392
|
+
# because in Rails 2.3.6 ActionView::SafeBuffer exists
|
393
|
+
# but is a deprecated proxy object.
|
394
|
+
return ActiveSupport::SafeBuffer if defined?(ActiveSupport::SafeBuffer)
|
395
|
+
return ActionView::SafeBuffer
|
379
396
|
end
|
380
397
|
|
381
398
|
## Cross-Ruby-Version Compatibility
|