Frage

link_to "hi",content_tag(:p,"hello")

produces me "<a href=\"&lt;p&gt;hello&lt;/p&gt;\">hi</a>" i don't want the escaped output. how to get a html_safe string?

War es hilfreich?

Lösung

You reversed arguments order - see http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to

Correct syntax is link_to content, url so what you probably wanted to do is:

link_to content_tag(:p, "hello"), "some_url"

This will not be escaped. If what you need is indeed content_tag as url then you can add "html_safe" method at the end:

link_to "hi",content_tag(:p,"hello").html_safe

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top