As a sidenote: according to docs you usually read data files with the data.filename.object
format (i.e.: data.gallery1.title
), but it’s also possible to use the array format: data[filename].object
which is handy if you somehow compute that name or extract it from other objects.
Also, there is no need to use gallery: "gallery1"
named-property format. Just plain array will do:
- "gallery1"
- "gallery2"
if your masterfile only lists filenames of datafiles. And this format is expected by the code below. Back to the point. You can extract the names of data files from a master data file master_list.yml
:
data.master_list.each do |datafile|
data.datafile.title # title extracted from gallery1.yml, gallery2.yml, …
data.datafile.description # etc
end
So the code for generating proxies would be like:
data.master_list.each do |datafile|
proxy "/gallery/#{data.datafile.slug}.html", "/gallery/template.erb", locals: {localdata: data.datafile}, ignore: true
end
Pay attention that each datafile should include the field slug
, to use that code, and as local variable localdata
you get the whole data from a single datafile.