I am using Ruby link_to in a .erb file to link to a story. The title has an ampersand in it. I want the text displayed for title to show the ampersand and not be escaped.
My data is:
story = {"title"=>"Dungeons & Dragons has its own version of the Slender Man now", "url"=>"https://www.polygon.com/22436057/dungeons-dragons-slender-man-bagman-van-richtens-guide-to-ravenloft"}
My html code has:
<h4><%= link_to story[:title], story[:url], { 'data-analytics-link' => 'readmore' } %></h4>
Here is what the link looks like with the ampersand:
Dungeons & Dragons has its own version of the Slender Man now
I have tried updating the link_to
to be:
<h4><%= link_to h(story[:title]), story[:url], { 'data-analytics-link' => 'readmore' } %></h4>
but I get the same result.
How can I use link_to
so that the text for link shows the ampersand?