Util.html_escape() in erb file

I have this in my .erb file

<%= text_area_tag ‘text’, h(@text), :style => “width: 100%”, :rows => 6
%>
or
<%= text_area_tag ‘text’, html_escape(@text), :style => “width: 100%”,
:rows => 6 %>

and it does not actually escape the characters

This is what is in my page source

&lt;a
href=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;
this is what i say

Any ideas would be appreciated
Thanks

On 23 September 2010 04:44, Maz Z. [email protected] wrote:

This is what is in my page source

&lt;a
href=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;
this is what i say

What is in @text and what did you expect the html to look like?

Colin

Colin L. wrote:

On 23 September 2010 04:44, Maz Z. [email protected] wrote:

This is what is in my page source

�&lt;a
href=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;
this is what i say

What is in @text and what did you expect the html to look like?

Colin

Hi

My question was not clear, I am seeing text in the textarea instead of
html

@text is
&lt;ahref=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;this
is what i say

and what I want to see is
LetterAttack this is what i say

Thanks

On 23 September 2010 09:20, Maz Z. [email protected] wrote:

Colin
is what i say

and what I want to see is
LetterAttack this is what i say

So, for example, you have the string “&lt;” and you want want to
convert it to “<”?
I think that could be tricky, it is certainly not what is meant by
escaping, it is more de-escaping. Can you not start with the text in
a simpler form before it is escaped? If you have only a limited set
of substrings that need converting
then I think you may just have to write code to convert them.

Colin

html_scape does that , you are causing the output

Don’t do anything and the escaped characters will appear as you
intend.

in view code:
<% text = "  <a href=  “http://www.blahblah.org/
blah”>LetterAttack…</a >
is what i say" -%>

<%= text -%>

renders like this:
LetterAttack…
is what i say

Phillip wrote:

Don’t do anything and the escaped characters will appear as you
intend.

in view code:
<% text = "  <a href=  “http://www.blahblah.org/
blah”>LetterAttack…</a >
is what i say" -%>

<%= text -%>

renders like this:
� <a href=� “http://www.blahblah.org/blah”>LetterAttack…
is what i say

In the textarea on the html page it is rendering like
&lt;ahref=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;this
is what i say

it is not
LetterAttack this is what i say
in the textarea

@text; h(@text); html_escape(@text) in the .erb file all display
&lt;ahref=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;this
is what i say
in the textarea on the html page
(where @text is
&lt;ahref=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;this
is what i say)

I want it to display LetterAttack… is what i say

Thanks

On 24 September 2010 05:58, Maz Z. [email protected] wrote:

LetterAttack this is what i say
I want it to display Â
LetterAttack… is what i say

I am still confused I am afraid. Do you want it to display <a href
=… so that is exactly what appears on the screen, or do you want it
to display a link to the URL, showing the text LetterAttack?

Colin

Colin L. wrote:

On 24 September 2010 05:58, Maz Z. [email protected] wrote:

LetterAttack this is what i say
I want it to display Â
LetterAttack… is what i say

I am still confused I am afraid. Do you want it to display <a href
=… so that is exactly what appears on the screen, or do you want it
to display a link to the URL, showing the text LetterAttack?

Colin

Hi

I want to display html in the textarea i.e more like de-scaping as you
describe

<%= label_tag ‘text’, @text %>

<%= text_area_tag ‘text’, @text , :style => “width: 100%”, :rows => 6 %>

The label displays correctly i.e.
LetterAttack… is what i say

whereas in the textarea it is displayed as
&lt;ahref=&quot;http://www.blahblah.org/blah&quot;&gt;LetterAttack&lt;/a&gt;this
is what i say

Thanks

On 23 September 2010 15:03, Phillip [email protected] wrote:

renders like this:
LetterAttack…
is what i say

Will it not display <a href… on screen rather than generating an
html href tag?

Colin

add
.html_safe

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs