PageRenderTime 369ms CodeModel.GetById 366ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

#! | 24 lines | 20 code | 4 blank | 0 comment | 0 complexity | 464a3adfea5c5060e61eac8e2760e028 MD5 | raw file
 1Yamler - Making YAML easy and fun to use with Ruby
 4Using YAML in Ruby is pretty easy, but I find myself doing several things
 5every time I use YAML. First is I always seem to pass it through ERB. The
 6other is that I want to pass it a binding, because I want to give it
 7access to some variables or methods. Finally I sometimes end up merging
 8several YAML files into one file, because other wise it would be too big
 9and unwieldy to manage. Enter Yamler:
11=== Examples:
12  # Renders said file through ERB, and then through YAML.load:
13  Yamler.load('/path/to/file.yml')
15  # Does the same as above but makes a method called say_hi
16  # available to the binding of the Yamler::Template instance.
17  Yamler.load('/path/to/file.yml') do
18    def say_hi
19      'hi'
20    end
21  end
23  # Renders said file through ERB, and then through YAML.load:
24  Yamler.load('/path/to/file.yml', {:locals => {:username => 'markbates'}, :foo => :bar})