printString => greaseString => asJavascript

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

printString => greaseString => asJavascript

Nick
I've changed code in a couple of methods, where the code within a method generating javascript output has changed from: 
    id printString 
to:
    id greaseString 
The problem arises as the string is no longer surrounded by single quote marks, resulting incorrect javascript. The methods effected are:

Pier-EditorEnh  PRChangeCommand>>updateRoot
Pier-Documents PRDocumentWidget>>renderEditOn: 

My initial fix was to simply add the single double quote as: 

PRDocumentWidget >>renderEditOn: html  "Pier on Seaside 2.8"
| id |
self halt.
html textArea
value: self text;
class: 'wiki-inline';
id: (id := html nextId);
callback: [ :value | self text: value ];
onKeyUp: 'pier_document_widget_update(' , id printString , ')'.
self session
addLoadScript: 'pier_document_widget_register(' , id printString , ')'

becomes:

renderEditOn: html "Pier on Seaside 3.0"
| id |
self halt.
html textArea
value: self text;
class: 'wiki-inline';
id: (id := html nextId);
callback: [ :value | self text: value ];
onKeyUp: 'pier_document_widget_update(''' , id greaseString , ''')'.
html document
addLoadScript: 'pier_document_widget_register(''' , id greaseString , ''')'

However examining the code which executes when printString is called I noticed that it also escapes any quote marks in the string passed. On reflection I found the method asJavascript which appears to do the right thing. I've removed my extra speech marks, changed greaseString to asJavascript, and tested and all appears functional again. Have I found the right method? 


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: printString => greaseString => asJavascript

Lukas Renggli
> However examining the code which executes when printString is called I
> noticed that it also escapes any quote marks in the string passed. On
> reflection I found the method asJavascript which appears to do the right
> thing. I've removed my extra speech marks, changed greaseString to
> asJavascript, and tested and all appears functional again. Have I found the
> right method?

Yes, #asJavascript is the right method.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki