Skip to content

Commit d3bd380

Browse files
committed
remove development monkey patch
1 parent 5a931b4 commit d3bd380

File tree

1 file changed

+0
-44
lines changed

1 file changed

+0
-44
lines changed

lib/haml_coffee_assets/rails/engine.rb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,50 +33,6 @@ class Engine < ::Rails::Engine
3333
end
3434
end
3535

36-
if ::Rails.env == "development"
37-
# Monkey patch rails so it busts the server cache for templates
38-
# depending on the global_context_asset.
39-
#
40-
# Currently, the only way to force rails to recompile a server template is to
41-
# touch it. This is problematic because when the global_context_asset
42-
# changes we need to manually touch every template that uses the congtext
43-
# in some way.
44-
#
45-
# To ease development, make rails 'touch' and recompile hamlc templates
46-
# when the global context has changed.
47-
#
48-
# Do this ONLY in development.
49-
#
50-
# TODO: Don't monkey patch rails.
51-
module ::ActionView
52-
class Template
53-
def stale?
54-
return false unless ::Rails.env == "development"
55-
return false unless handler.respond_to?(:stale?)
56-
handler.stale?(updated_at)
57-
end
58-
59-
alias_method :old_render, :render
60-
61-
# by default, rails will only compile a template once
62-
# path render so it recompiles the template if 'stale'
63-
def render(view, locals, buffer = ::ActionView::OutputBuffer.new, &block)
64-
if @compiled and stale?
65-
now = Time.now
66-
File.utime(now, now, identifier) # touch file
67-
::Rails.logger.info "Busted cache for #{identifier} by touching it"
68-
69-
view = refresh(view)
70-
@source = view.source
71-
@compiled = false
72-
end
73-
old_render(view, locals, buffer, &block)
74-
end
75-
76-
end
77-
end
78-
end
79-
8036
config.assets.configure do |env|
8137
if env.respond_to?(:register_transformer)
8238
env.register_mime_type 'text/hamlc', extensions: ['.hamlc']

0 commit comments

Comments
 (0)