@@ -33,50 +33,6 @@ class Engine < ::Rails::Engine
33
33
end
34
34
end
35
35
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
-
80
36
config . assets . configure do |env |
81
37
if env . respond_to? ( :register_transformer )
82
38
env . register_mime_type 'text/hamlc' , extensions : [ '.hamlc' ]
0 commit comments