class Middleman::CoreExtensions::Data
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, config={}, &block)
def initialize(app, config={}, &block) super @data_store = DataStore.new(app, DATA_FILE_MATCHER) 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.join(app.root, dir), 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