Allow options injection for to_yaml
This makes it possible to inject formatting options into the to_yaml function.