Hi everybody,

while trying to migrate one of my projects to use haml, I noticed a
problem with JavaScript escaping when using link_to_function. E.g. in
haml:

=link_to_function('test', 'alert("test")')

results in:

<a href="#" onclick="alert("test"); return false;">test</a>

which does not work (JS runtime error if you click the link) since the
JS string isn't escaped properly. Using erb, the result would be:

<a href="#" onclick="alert(&quot;test&quot;); return false;">test</a>

In this case, this problem could be worked around by manually escaping
the JS string. However, actually I used a page update block with
link_to_function:

=link_to_function('add') { |page| page[:add_entry].show }

which does not work since it generates the JS string $
("add_entry").show() that isn't escaped.

I found a related post on the old rails bugtracker with a similar
problem: http://dev.rubyonrails.org/ticket/11583. Is this a haml bug,
or am I doing something wrong? Is there a way to work around or fix
it?

Btw, I'm using latest rails and haml plugin from git.

regards,
Andreas Neuhaus

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to