1

Given the following Cheetah template

#filter None
{data:[
#for $person in $persons
{naam: "#if $person.lastname==None then '' else $person.lastname.replace('"', '\\"')#}, 
#end for
]}
#end filter

That's quite a mouthful for replacing " with \\"

Anyone has an easier/shorter way of writing this expression?

Paul
  • 1,068
  • 11
  • 29

1 Answers1

0

I do not know Cheetah, but maybe this works:

{naam: "#$person.lastname and $person.lastname.replace('"', '\\"')#}, 
Marco de Wit
  • 2,686
  • 18
  • 22
  • Nope, the #if ... then ... else ...# seems to be evaluated by Cheetah and not by Python – Paul Jul 21 '12 at 10:26