Sungpah Lee
Sungpah Lee

Reputation: 1021

String rendering method

If I put the below code in .rb file

@expression_display = "Hi hello my name is <code>man</code>"

And in html.erb,

<%= @expression_display %>

But the display looks just like

Hi hello my name is <code>man</code>

, not the one with "man" part highlighted.

If I just put this sentence in html file, the "man" part will be highlighted because this part followed the code command.

How can I make this properly :) ?

Upvotes: 1

Views: 53

Answers (2)

Omid Kamangar
Omid Kamangar

Reputation: 5778

If you are using Rails, you can use html_safe like this:

<%= @expression_display.html_safe %>

Upvotes: 4

jazzytomato
jazzytomato

Reputation: 7214

You can use <%= raw(@expression_display) %>

raw doesn't escape the string. see the doc here

Upvotes: 2

Related Questions