class Middleman::CoreExtensions::Data::DataExtension
and makes them available to ‘config.rb`, templates and extensions
The data extension parses YAML and JSON files in the `data/` directory
def after_configuration
def after_configuration return unless @original_data_dir != app.config[:data_dir] @watcher.update_path(app.config[:data_dir]) end
def initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block)
def initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block) super @data_store = DataStoreController.new(app, app.config[:track_data_access]) start_watching(app.config[:data_dir]) end
def start_watching(dir)
def start_watching(dir) @original_data_dir = dir # Tell the file watcher to observe the :data_dir @watcher = app.files.watch :data, path: File.expand_path(dir, app.root), only: DATA_FILE_MATCHER # Setup data files before anything else so they are available when # parsing config.rb app.files.on_change(:data, &@data_store.method(:update_files)) end