Hi you all, I have a weird problem escaping characters.
The user types in a text area the following: Hello
When the page is rendered with the .to_html of RedCloth this works.
(I’m using a Javscript code called CoolTip, that, when the mouse is over
a word or words with this javascript, a tip appears. In this tip, a link
can be written. The whole sentence about is the called to the
javascript, but this is not important)
I don’t want the user to type this stuff. So, I write that in rails, in
a string:
But this does not work; what rails renders is a mess. Am I doing
something wrong escaping the rare characters? Cause the code at the very
beginning does work, so the problem isn’t RedCloth or the javascript
call…
Can you maybe boil it down to a smaller example? The only thing I can
think of is maybe it’s un-escaping the characters too many times, or
not enough times.
Yes; I was kind of desperate and I just threw the whole stuff
I have to write this code, for a Javscript function:
onmouseover=“coolTip(’<a
href=’/wiki/show_appears?value=Fidel+Castro&name=primaryCharacter’>Appears…</a>’,
STICKY,MOUSEOFF);”
If I write this in a text area, as it is, and then I render the page,
everything is ok. However, this whoole string will be given as a
variable in my app. So I tried with this:
semantic_link = ‘onmouseover="coolTip(’<a
href=\’/wiki/show_appears?value=Fidel+Castro&name=primaryCharacter\’
>Appears…</a>’, STICKY, MOUSEOFF);"’
The problem is in the a href=\’/wiki/ …
If i put 2 backslashes (to return a backslash), and another one to
return the ',
what rails render is a dot. I ve tried with other combinations but…
they didn’t work! How can I do it?
If I hardcode the anchor tag in my rhtml file as follows it works fine
for me. I did have to dispense with the \ though. However, I get the
impression you were not hardcoding this in your view. If your still
having trouble with it, post your controller and view code.
Ok, I understand you need to change it programmatically. I added the \
back in, put it in a string assigned to an instance variable and did a
simple render in the view. It seems to work just fine for me. Here is
the string in my controller:
Ok, I understand you need to change it programmatically. I added the \
back in, put it in a string assigned to an instance variable and did a
simple render in the view. It seems to work just fine for me. Here is
the string in my controller:
No, sorry It does not work for me. The three backslashes turned into
a dot.
Dunno why I’m not using RedCloth at all, I just throw the variable as
you in the rhtml. Can it be the Rails version? I’m using rails 1.1.4
If I hardcode the anchor tag in my rhtml file as follows it works fine
for me. I did have to dispense with the \ though. However, I get the
impression you were not hardcoding this in your view. If your still
having trouble with it, post your controller and view code.
This anchor tag also works for me if I write it as it is in a rhtml
file. But I have to generate it from the application. So I have to write
the anchor inside a string (cause the link /wiki/show… will change
depending on several things). My problem is having the anchor tag inside
a string variable in rails.
I was using rails v1.1.2 but I just upgraded to v1.1.6 and it still
works fine for me. I am using Ruby v1.8.4 on a Windows XP box. I guess
at this point I would check the development.log to see if there is
something in there that might give you a clue. I suppose it’s also
possible a plug-in might be causing the problem Otherwise, I think your
only recourse is to rebuild the environment by installing a clean
version of ruby on rails. Don’t install any plug-ins and give it
another shot.
Damaris - if you can post an example of working code that fails I think
we can figure this out. Show me a real code fragment, something I can
recreate on my end.
It seems we need to add another set of double backslashes to get the
desired results. I don’t understand this as the documentation says that
on a single quoted string that a double backslash converts to a single
backslash.
It seems we need to add another set of double backslashes to get the
desired results. I don’t understand this as the documentation says that
on a single quoted string that a double backslash converts to a single
backslash.
It seems we need to add another set of double backslashes to get the
desired results. I don’t understand this as the documentation says that
on a single quoted string that a double backslash converts to a single
backslash.