I’m looking for help to try and reparse data when files are changed.
To give some background, I’ve written an extension for middleman that contains a class which reads & validates yaml files in data
. Then I activate this extension in config.rb
.
Within the extension I’ve defined a method (panels
) that parses and memoizes the files in data
and is exposed to the templates, something like:
class Panels < Middleman::Extension
expose_to_template :panels
def initialize(app, options_hash={}, &block)
@data = app.data
super
end
def panels
@panels ||= DataParser::Data.all(@data)
end
end
So at the moment it parses and validates app.data, but in principal could just re-read the yaml files.
This works great, however, it would be even better if I could break the cached data (in @panels
) when the files are edited. However, I’m struggling to find a way to do this. Any help much appreciated.
Related to these topics: