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

/tools/Ruby/lib/ruby/gems/1.8/gems/yamler-0.1.0/README

http://github.com/agross/netopenspace
#! | 24 lines | 20 code | 4 blank | 0 comment | 0 complexity | 464a3adfea5c5060e61eac8e2760e028 MD5 | raw file
 1Yamler - Making YAML easy and fun to use with Ruby
 2=========================================================================
 3
 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:
10
11=== Examples:
12  # Renders said file through ERB, and then through YAML.load:
13  Yamler.load('/path/to/file.yml')
14
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
22  
23  # Renders said file through ERB, and then through YAML.load:
24  Yamler.load('/path/to/file.yml', {:locals => {:username => 'markbates'}, :foo => :bar})