You could also define the string in the controller and pass it to the view:

def action():
    return dict(mystring=PRE('{{this is a string}}'))

View:
{{=mystring}}

Or if you need to do this frequently in views, you could define a special 
helper:

class BRACE(DIV):
    def xml(self):        
        return '{{' + self._xml()[1] + '}}'

{{=BRACE('this is a string'}}

will output:

{{this is a string}}

Anthony

On Wednesday, January 18, 2012 9:46:33 AM UTC-5, Massimo Di Pierro wrote:
>
> Because the {{ ....}} operator have precedence over everything else. 
> when web2py finds 
>
> {{=PRE("{{this is a string}}"))} 
>
> interprets it as 
>
> OPEN{{  =PRE("{{this is a string    CLOSE}}            "))} 
>
> when you want to put < and > in HTML you have to escape them with &lt; 
> and &gt; 
>
> similarly if you want to put {{ and }} inside web2py views you have to 
> escape them. In your case the simples solution is: 
>
> {{=PRE("{"+"{this is a string}"+}"))} 
>
>
>
>
> On Jan 18, 7:59 am, davidjensen <[email protected]> wrote: 
> > It bombs on PRE, CODE, and now XML 
> > 
> > On Jan 18, 3:13 am, nils <[email protected]> wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > Hi, 
> > > Could you not use {{=XML(string...)}} 
> > > Regards, 
> > > Nils 
> > > On Jan 18, 2012 9:43 a.m., "davidjensen" <[email protected]> 
> wrote: 
> > 
> > > > This is not recognized asa string: 
> > > > "{{this is a string}}"     in: 
> > > > {{=PRE("{{this is a string}}"))}    in a web page 
> > > > but it works on the command line: 
> > > > >>PRE("{{this is a string}}").xml()

Reply via email to