/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

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