[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ERB question

Robert D. La Gesse

3/16/2006 5:01:00 PM

Can anyone tell me what the difference is in these two statements? Yes,
I'm a newbie!

<%=h device.send(column.name) %>

<%= device.send(column.name) %>

Specifically, what is the <%=h supposed to do? The "h" doesn't appear
to do anything that I can find, yet RoR generates code using it...

Thanks much!

Rob
3 Answers

Markus Werner

3/16/2006 5:07:00 PM

0

Robert D. La Gesse wrote:
> Can anyone tell me what the difference is in these two statements? Yes,
> I'm a newbie!
>
> <%=h device.send(column.name) %>
>
> <%= device.send(column.name) %>
>
> Specifically, what is the <%=h supposed to do? The "h" doesn't appear
> to do anything that I can find, yet RoR generates code using it...
>
> Thanks much!
>
> Rob

h is a short form for is a short form for the method html_escape.

So IMHO it's more clear to write something like
<%= h(device.send(column.name)) %>


cu

polarix

Robert D. La Gesse

3/16/2006 5:10:00 PM

0

Markus Werner wrote:
> Robert D. La Gesse wrote:
>> Can anyone tell me what the difference is in these two statements? Yes,
>> I'm a newbie!
>>
>> <%=h device.send(column.name) %>
>>
>> <%= device.send(column.name) %>
>>
>> Specifically, what is the <%=h supposed to do? The "h" doesn't appear
>> to do anything that I can find, yet RoR generates code using it...
>>
>> Thanks much!
>>
>> Rob
>
> h is a short form for is a short form for the method html_escape.
>
> So IMHO it's more clear to write something like
> <%= h(device.send(column.name)) %>
>
>
> cu
>
> polarix
>
OK, I guess that's clear enough... but it doesn't actually seem to make
any difference if the "h" is in there or not. And I can't seem to
determine why Ruby on Rails sometimes generates code with the "h", and
sometimes it doesn't :)

Thank,

Rob

James Gray

3/16/2006 5:20:00 PM

0

On Mar 16, 2006, at 11:13 AM, Robert D. La Gesse wrote:

> Markus Werner wrote:
>> Robert D. La Gesse wrote:
>>> Can anyone tell me what the difference is in these two
>>> statements? Yes,
>>> I'm a newbie!
>>>
>>> <%=h device.send(column.name) %>
>>>
>>> <%= device.send(column.name) %>
>>>
>>> Specifically, what is the <%=h supposed to do? The "h" doesn't
>>> appear
>>> to do anything that I can find, yet RoR generates code using it...
>>>
>>> Thanks much!
>>>
>>> Rob
>> h is a short form for is a short form for the method html_escape.
>> So IMHO it's more clear to write something like
>> <%= h(device.send(column.name)) %>
>> cu
>> polarix
> OK, I guess that's clear enough... but it doesn't actually seem to
> make any difference if the "h" is in there or not. And I can't
> seem to determine why Ruby on Rails sometimes generates code with
> the "h", and sometimes it doesn't :)

Try:

<%= h "< & >" %>

and:

<%= "< & >" %>

James Edward Gray II