Reputation: 567
I'm using the pretty neat magick title gem for converting text into images. I'm having a small issue on which I've been stuck for the past two hours. The idea of the gem is that once installed, all one needs to do is..
MagickTitle.say("Hello").to_html(false)
..and the above will create an image, and write out the html for displaying it..
<img class="magick-title" src="/system/titles/hello_163659704286b7f0990ac2364ea9de8dbf8664be.png" alt="hello"/>
So what I do in my code (a view) is the following..
<%= MagickTitle.say("hello").to_html(false) %>
but on my page where I'm expecting the image of the word hello to show up, I'm only seeing the html (img tag html pasted above) getting printed out as is. I did a view source of the page and saw the issue..the html for the image in the page source shows up as..
<img class="magick-title" src="/system/titles/hello_163659704286b7f0990ac2364ea9de8dbf8664be.png" alt="hello"/>
So the html tags < and > in the page html are showing up as & l t ; and & g t ; which are codes for the opening and closing tags. Any ideas how to make this not happen?
Thanks!
Upvotes: 0
Views: 211
Reputation: 46914
It's because you need mark this return like html_safe or use raw
<%= raw MagickTitle.say("hello").to_html(false) %>
Upvotes: 2