Re: Fwd: Fwd: Filtering a template block
"R. Tyler Ballance" <[email protected]>
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
On Sun, May 17, 2009 at 10:34:10PM -0700, [email protected] wrote: > > > What is #call > myMethod/ #end call syntax? This is where I lament the state of Cheetah's documentation. Try it out :) #call $myMethod Foo #end call Will result in $myMethod(u'Foo') > > And if it is easy can you add it > I can think of so many cases where we can do this > > #transform CodeHighlight > code > #end transform > html > #tranform footer > > #end transform As I said, it's not easy to do. You can accomplish the same thing with a function however: #def giveMeCodePlz() #transform CodeHighlight <code goes here> #end def $giveMeCodePlz() html I inadvertantly added #transform before seeing #call and #capture (both actually exist, #call executing a method with the result of a block, #capture storing the result of a block in a variable). I suppose I'll leave them all around for now, but I think there's some redundancy redundancy here here. > > On Sun, May 17, 2009 at 10:29 PM, R. Tyler Ballance <[email protected]> > wrote: > > On Sun, May 17, 2009 at 10:27:18PM -0700, [email protected] > wrote: > > is it easy to add #end transform > > it will be easier to use #transform with #end > > imho > > It's not at all, I don't plan on adding it to be honest. If you need to > *really* use something like it with an #end, you can try defining a > method to perform your transformations, and then using the #call > myMethod/ #end call syntax > > > thanks > > > > > > On 5/17/09, R. Tyler Ballance <[email protected]> wrote: > > > > On Sun, May 17, 2009 at 10:18:11PM -0700, > [email protected] > > wrote: > > > so if we use > > > > > > Some data > > > #transform foo > > > This is $something > > > #end transform > > > Some other data > > > > > > will Some data > > > and Some other data > > > > > > not be transformed? which means it works like filter > > > > The #transform directive has no '#end transform' corrolary. It > affects > > the rest of the logical block. I.e. > > > > #def myMethod() > > #transform Foo > > > > This is something > > > > Blah blah > > #end def > > > > The entire output of "myMethod()" will be passed through "Foo" > > > > > On 5/17/09, R. Tyler Ballance <[email protected]> wrote: > > > > > > On Sun, May 17, 2009 at 10:07:55PM -0700, > > [email protected] > > > wrote: > > > > *So to mod a snippet we use #filter* > > > > *to mod the entire page we use #transform?* > > > > > > #filter only applies to the placeholders (i.e. > '$variable') > > inside of a > > > given block. > > > > > > #filter foo > > > This is $something > > > #end filter > > > > > > In this example "foo" will have the value of "something" > passed > > through. > > > > > > If you use the #transform direction, you can do this: > > > > > > #transform foo > > > This is $something > > > > > > "foo" will receive the entire contents "This is > $something" to > > > transform. > > > > > > So short answer, yes, you can mod the whole page, with > just > > #transform > > > at the top, and specifying a Cheetah.Filters.Filter > subclass as > > the > > > argument. > > > > > > Cheers > > > > > > > > > > > I was hoping to demonstrate how fun this is with the > changes I > > made to > > > > the communitycheetah.org web site earlier, given how I > > implemented the > > > > #transform directive, you can *actually* use it within > methods > > as well > > > > as for the whole document :) > > > > > > > > For example: > > > > > > > > #from Cheetah.Filters import Markdown > > > > > > > > #def $doSomethingFun() > > > > #transform Markdown > > > > Community Cheetah > > > > ================= > > > > > > > > Can be found > [here](http://www.communitycheetah.org) > > > > #end def > > > > > > > > Will work just fine! Calling $doSomethingFun() will > return the > > > generated > > > > Markdown for the text, and you can get nice HTML as a > result. > > > > > > > > My goal was to provide a simple interface for modifying > large > > chunks > > > of > > > > text, and Markdown makes it *really* easy to write > markup (in a > > > > wiki-like syntax) that can be presented as HTM > > > > > > > > On Sun, May 17, 2009 at 10:03 PM, R. Tyler Ballance > > <[email protected]> > > > wrote: > > > > > > > > > This is effectively what the #transform directive does > :) > > > > > > > > > > > > > > > On Sun, May 17, 2009 at 10:01:22PM -0700, > > [email protected] > > > wrote: > > > > > > ---------- Forwarded message ---------- > > > > > > From: Graham Dennis <[email protected]> > > > > > > Date: Tue, May 20, 2008 at 3:51 PM > > > > > > Subject: Re: [Cheetahtemplate-discuss] Filtering > a > > template > > > block > > > > > > To: Dennis Kempin <[email protected]> > > > > > > Cc: [email protected] > > > > > > > > > > > > Dennis. > > > > > > Another way to achieve this would be with the > #capture > > > directive to > > > > > > capture the string you want to filter, and then > use a > > #filter > > > and a > > > > > > variable replacement to do the job. > > > > > > > > > > > > For example: > > > > > > -------------------------------- > > > > > > <p>Here is some example:</p> > > > > > > #capture stringToHighlight > > > > > > int main() { > > > > > > std::cout << "Hello Cheetah!" << > std::endl; > > > > > > } > > > > > > #end capture > > > > > > #filter $myCPPHighlighter > > > > > > ${stringToHighlight}#slurp > > > > > > #end filter > > > > > > <p>And it goes on without highlighting</p> > > > > > > --------------------------------- > > > > > > > > > > > > This essentially works how your hacked-up version > does > > except > > > Cheetah > > > > > > does the hacking for you. > > > > > > > > > > > > Cheers, > > > > > > Graham > > > > > > > > > > > > On 20 May 2008, at 8:34 PM, Dennis Kempin wrote: > > > > > > > > > > > > > Hi again, > > > > > > > > > > > > > > I want to extend my post. > > > > > > > I have "hacked" some solution using psp style > tags: > > > > > > > <% > > > > > > > self.source = "" > > > > > > > def writeSource(msg): > > > > > > > self.source += msg > > > > > > > originalWrite = write > > > > > > > write = writeSource > > > > > > > %> > > > > > > > int main() { > > > > > > > std::cout << "Hello Cheetah!" << > std::endl; > > > > > > > } > > > > > > > <% > > > > > > > write = originalWrite > > > > > > > source = self.source # + do some highlight > > > > > > > write("<pre>"+source+"</pre>") > > > > > > > %> > > > > > > > I dont know how the buildin #for, #if, etc > elements > > are > > > implemented. > > > > > > > But is it possible to extend them and get the > above > > code > > > wrapped > > > > > > > into some > > > > > > > syntax like this: > > > > > > > # highlight c++ > > > > > > > int main() { > > > > > > > std::cout << "Hello Cheetah!" << > std::endl; > > > > > > > } > > > > > > > # end highlight > > > > > > > I cannot find any documentation on how to > extend these > > > > > functionality. > > > > > > > > > > > > > > Thanks alot, > > > > > > > Dennis > > > > > > > > > > > > > > > > > > > > > On Tuesday 20 May 2008 12:21:33 Dennis Kempin > wrote: > > > > > > >> Hello, > > > > > > >> > > > > > > >> I am using cheetah to create some kind of > ultra-light > > > content > > > > > > >> managment > > > > > > >> system for personal use. > > > > > > >> As I use a lot of code snippets in my pages I > want to > > > provide a way > > > > > > >> to > > > > > > >> perform syntax highlighting on a specific > template > > block. > > > > > > >> > > > > > > >> -------------------------------- > > > > > > >> <p>Here is some example:</p> > > > > > > >> # now pass everything between this and the end > tag > > through a > > > syntax > > > > > > >> highlighter > > > > > > >> int main() { > > > > > > >> std::cout << "Hello Cheetah!" << > std::endl; > > > > > > >> } > > > > > > >> # end highlight > > > > > > >> <p>And it goes on without highlighting</p> > > > > > > >> --------------------------------- > > > > > > >> > > > > > > >> Is something like this possible with cheetah? > Filters > > only > > > work on > > > > > > >> $variables and I dont have any idea how to > implement > > this. > > > > > > >> > > > > > > >> regards, > > > > > > >> Dennis > > > > > > >> > > > > > > >> > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > >> This SF.net email is sponsored by: Microsoft > > > > > > >> Defy all challenges. Microsoft(R) Visual > Studio 2008. > > > > > > >> > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > > >> > _______________________________________________ > > > > > > >> Cheetahtemplate-discuss mailing list > > > > > > >> [email protected] > > > > > > >> > > > > > > > > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > > This SF.net email is sponsored by: Microsoft > > > > > > > Defy all challenges. Microsoft(R) Visual Studio > 2008. > > > > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > > > _______________________________________________ > > > > > > > Cheetahtemplate-discuss mailing list > > > > > > > [email protected] > > > > > > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------- > > > > > > This SF.net email is sponsored by: Microsoft > > > > > > Defy all challenges. Microsoft(R) Visual Studio > 2008. > > > > > > > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > > > > > _______________________________________________ > > > > > > Cheetahtemplate-discuss mailing list > > > > > > [email protected] > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss > > > > > > > > > > > > -- > > > > > > Bidegg worlds best auction site > > > > > > http://bidegg.com > > > > > > > > > > -- > > > > > -R. Tyler Ballance > > > > > Slide, Inc. > > > > > > > > > > > > > > > > > > > > > -- > > > > Bidegg worlds best auction site > > > > http://bidegg.com > > > > > > -- > > > -R. Tyler Ballance > > > Slide, Inc. > > > > > > -- > > > Bidegg worlds best auction site > > > http://bidegg.com > > > > -- > > -R. Tyler Ballance > > Slide, Inc. > > > > -- > > Bidegg worlds best auction site > > http://bidegg.com > > -- > -R. Tyler Ballance > Slide, Inc. > > -- > Bidegg worlds best auction site > http://bidegg.com > > -- > Bidegg worlds best auction site > http://bidegg.com > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited royalty-free distribution of the report engine > for externally facing server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > Cheetahtemplate-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss -- -R. Tyler Ballance Slide, Inc. ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Cheetahtemplate-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
signature.asc
(application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkoQ9OgACgkQFCbH3D9R4W9O7QCfSyEugbTBqZ5JVbVFiENVQEP5 AnMAoK1QSeuNQJSF8Z1Wg1kXwdr6CHCW =gf8a -----END PGP SIGNATURE-----