mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Expect non-String return values from with_output_buffer.
This commit is contained in:
parent
be8080b271
commit
2aab52cda5
3 changed files with 20 additions and 1 deletions
|
@ -18,6 +18,8 @@
|
||||||
|
|
||||||
* Don't crash when methods like `form_for` return `nil` in, for example, Rails 3 beta.
|
* Don't crash when methods like `form_for` return `nil` in, for example, Rails 3 beta.
|
||||||
|
|
||||||
|
* Compatibility with Rails 3 beta's RJS facilities.
|
||||||
|
|
||||||
## 2.2.21
|
## 2.2.21
|
||||||
|
|
||||||
[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21).
|
[Tagged on GitHub](http://github.com/nex3/haml/commit/2.2.21).
|
||||||
|
|
|
@ -99,7 +99,12 @@ module ActionView
|
||||||
module Helpers
|
module Helpers
|
||||||
module CaptureHelper
|
module CaptureHelper
|
||||||
def with_output_buffer_with_haml_xss(*args, &block)
|
def with_output_buffer_with_haml_xss(*args, &block)
|
||||||
Haml::Util.html_safe(with_output_buffer_without_haml_xss(*args, &block))
|
res = with_output_buffer_without_haml_xss(*args, &block)
|
||||||
|
case res
|
||||||
|
when Array; res.map {|s| Haml::Util.html_safe(s)}
|
||||||
|
when String; Haml::Util.html_safe(res)
|
||||||
|
else; res
|
||||||
|
end
|
||||||
end
|
end
|
||||||
alias_method :with_output_buffer_without_haml_xss, :with_output_buffer
|
alias_method :with_output_buffer_without_haml_xss, :with_output_buffer
|
||||||
alias_method :with_output_buffer, :with_output_buffer_with_haml_xss
|
alias_method :with_output_buffer, :with_output_buffer_with_haml_xss
|
||||||
|
|
|
@ -77,6 +77,9 @@ class TemplateTest < Test::Unit::TestCase
|
||||||
base.send(:_evaluate_assigns_and_ivars)
|
base.send(:_evaluate_assigns_and_ivars)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This is needed by RJS in (at least) Rails 3
|
||||||
|
base.instance_variable_set('@template', base)
|
||||||
|
|
||||||
# This is used by form_for.
|
# This is used by form_for.
|
||||||
# It's usually provided by ActionController::Base.
|
# It's usually provided by ActionController::Base.
|
||||||
def base.protect_against_forgery?; false; end
|
def base.protect_against_forgery?; false; end
|
||||||
|
@ -369,6 +372,15 @@ HTML
|
||||||
= f.text_field :title
|
= f.text_field :title
|
||||||
Body:
|
Body:
|
||||||
= f.text_field :body
|
= f.text_field :body
|
||||||
|
HAML
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_rjs
|
||||||
|
assert_equal(<<HTML, render(<<HAML, :action_view))
|
||||||
|
window.location.reload();
|
||||||
|
HTML
|
||||||
|
= update_page do |p|
|
||||||
|
- p.reload
|
||||||
HAML
|
HAML
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue