Well if the controller did the Escaping, then my suggestion will pass it 
back to the view untouched I think.
So it might help.

On Thursday, November 1, 2012 7:18:54 AM UTC-5, villas wrote:
>
> Hi dlypka,
>
> Not sure I was clear.  I need to maintain the escaping.
>
> My point was this:  my data was escaped OK in the controller,  but when it 
> arrived in the view,  it was not escaped.
> Something broke the escaping of single-quotes passing between the two.  
> Double quotes are a bit of problem too.
>
> We can work around the problem, but I thought there may be a proper 
> solution.
>
> Best regards,
> D
>
>
> On Thursday, November 1, 2012 12:05:44 PM UTC, dlypka wrote:
>>
>> I used this code in my controller:
>> result = '{ "IsLoggedIn": "%s", "resmsg": "%s"}' % (retIsLoggedIn, 
>> resmsg)   
>> response.headers['Content-Type'] = 'application/jsonp'
>> response.view = 'generic.jsonp' # Using python code in file 
>> init/views/generic.jsonp to leave data unescaped
>> return result
>>
>> On Wednesday, October 31, 2012 7:06:06 PM UTC-5, villas wrote:
>>>
>>> I have a problem with escaping single quotes when I need a JS list in my 
>>> view.  I have a workaround below,  but is there a better way?  
>>>
>>> In controller:
>>> lst = ["Andy's Barber Shop"]
>>> jsonlst = json.dumps(lst)
>>> '["Andy\'s Barber Shop"]'
>>>
>>> In view:
>>> {{=XML(jsonlst)}}
>>> '["Andy's Barber Shop"]'   <<<<--- Broken
>>>
>>> My Workaround:
>>> {{=XML(jsonlst.replace("'", "\\'")}}
>>> '["Andy\'s Barber Shop"]'   <<<<--- Works OK
>>>
>>>
>>>

-- 



Reply via email to