lib/nanoc-conref-fs/datafiles.rb in nanoc-conref-fs-0.3.1 vs lib/nanoc-conref-fs/datafiles.rb in nanoc-conref-fs-0.4.0

- old
+ new

@@ -15,10 +15,15 @@ match.gsub('~~#~~', '{{') end doc = YAML.load(content) data_keys = "#{path}".gsub(%r{^data/}, '').gsub(%r{/}, '.').gsub(/\.yml/, '').split('.') - create_nested_hash(data_keys, doc) + # we don't need to create a nested hash for root-level data files + if data_keys.length == 1 + { data_keys.first => doc } + else + create_nested_hash(data_keys, doc) + end end def self.create_nested_hash(keys, final) keys.reverse.inject do |mem, var| if mem == keys.last