Reputation: 604
Given the following YAML file:
---
foo: <%= $stdout %>
When I try to ERB this yaml file:
YAML.load(ERB.new(File.read(filename)).result)
I get the following result:
{"foo"=>nil}
Why isn't $stdout
resolving correct? If I put other ruby code in there, it works as expected.
Upvotes: 0
Views: 76
Reputation: 87406
Look at what you get when you just run ERB:
ERB.new("foo: <%= $stdout %>").result
The result is this:
foo: #<IO:0x0056078694db38>
So foo
will be set to nil
because #
is the comment character in YAML.
Upvotes: 2