Re: Can't Insert A Single Hash Character
Fred Ludlow <[email protected]> Tue, 15 Sep 2015 15:18:37 +0100
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <CAAgz+WLxYUa1cb+jRM2fU94zzDSf9WQ-pFEwosPqAweYd583DA@mail.gmail.com> |
--===============1133366668773191022== Content-Type: multipart/alternative; boundary=089e0141aa22ceec74051fc9dc5b --089e0141aa22ceec74051fc9dc5b Content-Type: text/plain; charset=UTF-8 Section 5 of the user guide says: "Placeholders and directives can be escaped by putting a backslash before them. \$var and \#if will be output as literal text" But obviously just putting \# doesn't work (see OP) This does work: s = """a \## b """ print Template(s) a # b i.e. \## and an extra blank line However, I'm guessing this isn't intended behaviour, so maybe don't rely on it! I've not looked at the source and don't know how Cheetah does it's parsing but I wonder if it's something to do with the precedence of one-line #if then else# statements, ##comments and escaped \#directives? That might be a red herring... Fred On 14 September 2015 at 20:59, Williams, James P2 < [email protected]> wrote: > > > If you want just the hash use the #raw function > > > > > > #raw > > > # > > > #end raw > > > > > > you'll get your hash this way. > > > > Excellent. I had forgotten about #raw. Thanks. > > > > Jim > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Cheetahtemplate-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > --089e0141aa22ceec74051fc9dc5b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Section 5 of the user guide says:<br>"Placeholders an= d directives can be escaped by putting a backslash before them. \$var and \= #if will be output as literal text"=C2=A0<div>But obviously just putti= ng \# doesn't work (see OP)<br><br>This does work:<br>s =3D ""= ;"a<br>\##<br><br>b<br>"""<br>print Template(s)<br>a<br= >#<br>b<br><br></div><div>i.e. \## and an extra =C2=A0blank line<br></div><= div><br>However, I'm guessing this isn't intended behaviour, so may= be don't rely on it!<br><br>I've not looked at the source and don&#= 39;t know how Cheetah does it's parsing but I wonder if it's someth= ing to do with the precedence of one-line #if then else# statements, ##comm= ents and escaped \#directives? That might be a red herring...<br><br>Fred<b= r><br><br>On 14 September 2015 at 20:59, Williams, James P2 <<a href=3D"= mailto:[email protected]">[email protected]</a>> wrote= :<br>><br>> > If you want just the hash use the #raw function<br>&= gt;<br>> ><br>><br>> > #raw<br>><br>> > #<br>><b= r>> > #end raw<br>><br>> ><br>><br>> > you'll g= et your hash this way.<br>><br>> =C2=A0<br>><br>> Excellent.=C2= =A0 I had forgotten about #raw.=C2=A0 Thanks.<br>><br>> =C2=A0<br>>= ;<br>> Jim<br>><br>> =C2=A0<br>><br>><br>> --------------= ----------------------------------------------------------------<br>><br= >> _______________________________________________<br>> Cheetahtempla= te-discuss mailing list<br>> <a href=3D"mailto:Cheetahtemplate-discuss@l= ists.sourceforge.net">[email protected]</a><br>= > <a href=3D"https://lists.sourceforge.net/lists/listinfo/cheetahtemplat= e-discuss">https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-dis= cuss</a><br>><br></div></div> --089e0141aa22ceec74051fc9dc5b-- --===============1133366668773191022== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ --===============1133366668773191022== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss --===============1133366668773191022==--