tags:

views:

70

answers:

1

when I do message.to_yaml I am getting the following output

mainText: "<h3 class=\"right_column\">Mark</h3> ... "

but I want the output in the following format

mainText: |
     <h3 class="right_column">Mark</h3>  
     ... 

How do you force ruby to use pipe to fold multiple lines of string.

I tried

message.to_yaml(:UseFold => true, :UseBlock => true)

but it is not working

Thanks

+1  A: 
irb(main):011:0> puts "Hi!\nIf your string has newlines...\nfolding is by default".to_yaml
--- |-
Hi!
If your string has newlines...
folding is by default
Marc-André Lafortune
Thanks.My string contained characters such as \xE2\xAC\x1C which was messing with the yaml. How do you fix the line below? puts "</p><!--<h3 class=\"right_column_heading\">P Sales Representative \xE2\xAC\x1C Central \n".to_yaml
surajz