1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

[Haml] Rails 2.3.6 compat: hack around the use of #safe_concat in #capture.

Closes gh-178
This commit is contained in:
Nathan Weizenbaum 2010-05-23 03:35:59 -07:00
parent 04fc2ef311
commit e2cadd6ed4
3 changed files with 29 additions and 5 deletions

View file

@ -97,6 +97,22 @@ module ActionView
end
end
# For some reason, Rails 2.3.6 uses #safe_concat in #capture
# even when XSS support is disabled.
if Haml::Util.ap_2_3_6?
module TextHelper
def concat_with_haml(string, binding = nil)
if is_haml?
haml_buffer.buffer.concat(string)
else
concat_without_haml(string, binding)
end
end
alias_method :concat_without_haml, :concat
alias_method :concat, :concat_with_haml
end
end
module TagHelper
def content_tag_with_haml(name, *args, &block)
return content_tag_without_haml(name, *args, &block) unless is_haml?

View file

@ -64,14 +64,10 @@ else
Haml::Template.try_enabling_xss_integration
end
require 'action_pack'
# Rails 2.3.6 monkeypatches ERB in incompatible ways.
# We fix our own subclass of ERB here so the Haml ERB filter
# will continue to work.
if defined?(ActionPack::VERSION::MAJOR) &&
ActionPack::VERSION::MAJOR == 2 &&
ActionPack::VERSION::MINOR == 3 &&
ActionPack::VERSION::TINY >= 6
if Haml::Util.ap_2_3_6?
class Haml::Filters::ERB::RealERB
def set_eoutvar(compiler, eoutvar = '_erbout')
compiler.put_cmd = "#{eoutvar}.concat"

View file

@ -324,6 +324,18 @@ module Haml
$1.to_i >= 3))
end
# Returns whether this environment is using ActionPack
# version 2.3.6 (or greater, up until 3.0.0).
#
# @return [Boolean]
def ap_2_3_6?
require 'action_pack'
defined?(ActionPack::VERSION::MAJOR) &&
ActionPack::VERSION::MAJOR == 2 &&
ActionPack::VERSION::MINOR == 3 &&
ActionPack::VERSION::TINY >= 6
end
# Returns an ActionView::Template* class.
# In pre-3.0 versions of Rails, most of these classes
# were of the form `ActionView::TemplateFoo`,