Closed rk closed 13 years ago
I would do something like this in your controller.rb
:
require 'yaml'
before 'index.html.haml' do
@yaml = YAML::load(File.read('index.yml'))
end
Then your YAML config would be available to your templates via @yaml
. Please comment back if this is not satisfactory and I'll reopen the ticket.
I'm liking the looks of Stasis so far, but I need to be able to embed a little YAML data in my files. I'm wanting to use Stasis to design a small web-magazine with multiple authors, and want to use the metadata to say who the author is (name/id) and use that knowledge in the controller to render a little partial for the author bio in the layout.
Now, I know that I could do this with file name conventions and pull it off of the actual filename. That'd work okay for a start I suppose, but I can't rename the output file. So it'd still have the author name and whatever metadata I embedded there.
I think this would be quite helpful for some site design elements, especially if the metadata is available both to controller and layout.