my_overflowed_stack my_overflowed_stack - 9 months ago 44
Ruby Question

Using a global ruby variable inside YAML

Given the following YAML file:

foo: <%= $stdout %>

When I try to ERB this yaml file:


I get the following result:


Why isn't
resolving correct? If I put other ruby code in there, it works as expected.


Look at what you get when you just run ERB:"foo: <%= $stdout %>").result

The result is this:

foo: #<IO:0x0056078694db38>

So foo will be set to nil because # is the comment character in YAML.