mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Work around a bug in the Rails #cache method.
Closes gh-149
This commit is contained in:
parent
c7eeb225fa
commit
bb59207327
2 changed files with 27 additions and 0 deletions
|
@ -169,6 +169,22 @@ module ActionView
|
|||
alias_method :form_for_without_haml, :form_for
|
||||
alias_method :form_for, :form_for_with_haml
|
||||
end
|
||||
|
||||
module CacheHelper
|
||||
# This is a workaround for a Rails 3 bug
|
||||
# that's present at least through beta 3.
|
||||
# Their fragment_for assumes that the block
|
||||
# will return its contents as a string,
|
||||
# which is not always the case.
|
||||
# Luckily, it only makes this assumption if caching is disabled,
|
||||
# so we only override that case.
|
||||
def fragment_for_with_haml(*args, &block)
|
||||
return fragment_for_without_haml(*args, &block) if controller.perform_caching
|
||||
capture(&block)
|
||||
end
|
||||
alias_method :fragment_for_without_haml, :fragment_for
|
||||
alias_method :fragment_for, :fragment_for_with_haml
|
||||
end
|
||||
else
|
||||
module FormTagHelper
|
||||
def form_tag_with_haml(url_for_options = {}, options = {}, *parameters_for_url, &proc)
|
||||
|
|
|
@ -401,6 +401,17 @@ window.location.reload();
|
|||
HTML
|
||||
= update_page do |p|
|
||||
- p.reload
|
||||
HAML
|
||||
end
|
||||
|
||||
def test_cache
|
||||
@base.controller = ActionController::Base.new
|
||||
@base.controller.perform_caching = false
|
||||
assert_equal(<<HTML, render(<<HAML, :action_view))
|
||||
Test
|
||||
HTML
|
||||
- cache do
|
||||
Test
|
||||
HAML
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue