awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.07k stars 454 forks source link

how can I get the output of ap into a variable? #90

Closed benlieb closed 11 years ago

benlieb commented 12 years ago

I often find myself wanting to put ap formated strings into

 tags, or into a database or simply store it in a variable?

Is this currently possible? I'm assuming I would have to turn off coloring, I just want the plain text, with formatting.

Thanks

thbar commented 12 years ago

Hi! (not the gem author here,but I had to use that as well).

Here's what I use:

variable.ai(:plain => true)
thbar commented 12 years ago

I'll add that you'll find other options (such as :index => false) on the readme:

https://github.com/michaeldv/awesome_print/

(but I think I discovered the ai method after looking at the code when providing a patch)

benlieb commented 12 years ago

Tnx for the reply. I actually found that myself by reading the source code. Good we came to the same conclusion ;)

jasonseney commented 11 years ago

@thbar - Thank you for the tip, when calling ap in my erb template, it was still sending the output to the console. Perhaps this is because I'm using Padrino + Sinatra and not loading ActiveView::Base?