2

I want to take as input text that takes the full greek name for a letter and displays it as a single greek letter. e.g. take 'alpha' and replace it with α.

My code looks like this

def name(y1)
    "&#{y1};"
end

with the output put into a html page using erb, i.e.

<%= name('alpha') %>

but the result is displayed in the html as &alpha; . How do I make it display α?

Obromios
  • 15,408
  • 15
  • 72
  • 127

1 Answers1

2

Based on: Disable HTML escaping in erb templates The escaping occurs in the ERB so you need to specify that the string is safe in the ERB.

Try this:

def name(y1)
    "&#{y1};"
end

<%= name('alpha').html_safe %>
Community
  • 1
  • 1
Aflah Bhari
  • 108
  • 2
  • 6