Class | Yamler::Template |
In: |
lib/yamler/template.rb
|
Parent: | Object |
options | [RW] | Options that are available to the YAML file. |
path | [RW] | The path of the YAML file to be rendered |
Takes the path to the YAML file you wish to render. An optional Hash of options can be passed in. These options are available via the options accessor. If there is a Hash in the options called :locals then the keys of that Hash are available as local methods.
Examples:
Yamler::Template.new('/path/to/file.yml', {:locals => {:username => 'markbates'}, :foo => :bar}) # in file.yml: username: <%= username %> # => 'markbates' foo: <%= options[:foo] %> # => :bar
Runs the YAML file through ERB using either the current templates binding or the specified one. This method returns a string and NOT a YAML object.
Requires another YAML file from inside the current YAML file. The contents of the required YAML file will be run through ERB with the binding of the requiring YAML file and it‘s output will be appended to the calling YAML file. The ’.yml’ extension is optional. It will be added on if the extension is blank. If the file does not exist, it will look for it in the current directory. If it does not exist there it will raise an error.
Examples:
<%= require_yaml('foo') %> # => <current_yml_files_directory>/foo.yml <%= require_yaml('foo.yml') %> # => <current_yml_files_directory>/foo.yml <%= require_yaml('/usr/foo.yml') %> # => /usr/foo.yml