#from Cheetah.Utils.htmlEncode import htmlEncode #################### ## Class attributes: #attr navBarSep = '
#block headTagContents ' #attr title = 'Cheetah - The Python-Powered Template Engine' #attr htmlExt = '.html' #attr pageId = 'index' ## $apos used to avoid a syntax highlight issue in Emacs: #attr apos = ''' #attr currentYear = time.strftime("%Y",time.localtime(time.time())) ################################################################################ ## Everything outsite of '#blocks' from here to the next set of 3 commment bars ## is part of the template's .respond() method. .respond() is the default ## method and is linked into the template's __str__ method. ################################################################################ #block doctypeEtc #end block
Cheetah is an open source template engine and code generation tool written in Python. It can be used standalone or combined with other tools and frameworks. Web development is its principle use, but Cheetah is very flexible and is also being used to generate C++ game code, Java, sql, form emails and even Python code. Cheetah has a large and active user community. Products built with Cheetah are used by many of the Fortune 500. One prominent new user is reddit.com, a startup funded by Paul Graham. |
#set sep=' | '
$shortPraiseSection
read more quotes
|
Cheetah:
Its design was guided by these principles:
A clean separation makes it easier for a team of content writers, HTML/graphic designers, and programmers to work together without stepping on each other's toes and polluting each other's work. The HTML framework and the content it contains are two separate things, and analytical calculations (program code) is a third thing. Each team member should be able to concentrate on their specialty and to implement their changes without having to go through one of the others (i.e., the dreaded "webmaster bottleneck").
While it should be easy to develop content, graphics and program code separately, it should be easy to integrate them together into a website. In particular, it should be easy:
Cheetah was created by Tavis Rudd, a freelance programmer and designer, with contributions from many open source volunteers. Its documentation is edited by Mike Orr, who also wrote its command line tool.
We$(apos)d like to thank the following people for contributing valuable advice, encouragement, code and bug reports:
The Velocity, WebMacro, Smarty and Mason projects provided inspiration and design ideas. Cheetah has benefited from the creativity and energy of their developers. Thank you.
On a historical note, Cheetah is one of several templating frameworks that grew out of a "templates" thread on the Webware for Python email list.
#end def ################################################################################ #def learnPageContentsNote, the official documentation describes Cheetah 1.0. We are in the process of updating it to include the changes in the 2.0 release. For the time-being, the changes in 2.0 are described in the module docstrings and in the CHANGES log.
Cheetah Users' Guide: ##' HTML Multi-page HTML Postscript Text PDF
Cheetah Developers$(apos) Guide: HTML Multi-page HTML Postscript Text PDF
Also see the latest CHANGES, TODO, BUGS.
The LaTeX source for the Users' Guide and Developers' Guide is in the CVS module CheetahDocs at SourceForge, http://sourceforge.net/cvs/?group_id=28961.
Building and filling out templates with Python and Cheetah by Leonard Richardson, Software Engineer at CollabNet. Published in IBM Developer Works, August 9th, 2005. Leonard Richardson is the author of many Python applications and libraries, including NewsBruiser and Beautiful Soup. He is a co-author of the new tome Beginning Python, from Wrox.
Python-Powered Templates with Cheetah by Andrew Glover, founder and CTO of Vanward Technologies, a company specializing in building automated testing frameworks. Published in O'Reilly's ONLamp.com, January 13th, 2005
Templating with Cheetah, a DevShed article by Peyton McCullough. Published in December 2005.
The Python10 conference paper about Cheetah, by Tavis Rudd, Mike Orr, and Ian Bicking. It provides a high-level introduction to Cheetah and the philosophy behind its design. Published in December 2001.
Templating in Python, a Linux Gazette article by Mike Orr. Published in Issue 117 of Linux Gazette, August 2005.
Tierisch gut Das Cheetah Templating-System in der Praxis, a German-language article by Markus Jais. Published in the December 2004 edition of http://www.linuxenterprise.de/.
One-Page Tutorial for template maintainers. Covers a few basic concepts.
Python Success Stories: Python Enterprise-Wide at the University of St Andrews in Scotland by Hamish Lawson. Cheetah is used for the presentation layer. Hamish Lawson is a software developer in the IT Services department at the University of St Andrews, Scotland. Published January 17th, 2003.
Code Generation Network - Case Study with Peter White, an interview that discusses using Cheetah for generating Java code in a financial services application. "Given my recent experience with Python and Cheetah, I can't imagine an easier way to generate code!" Published March 1st, 2004.
Cheetah is covered in Python in a Nutshell, by Alex Martelli. Alex writes on the Cheetah list: "Nutshell readers looking for templating engines will be tempted by my ultra-brief coverage enough to come visit the Cheetah site and get stunned. Indeed, I'm impressed enough that I plan to cover _only_ Cheetah as the one tool for any serious templating need."
It is also introduced in the New Riders book Python Web Programming, by Steve Holden. Steve writes "Although the software is still in beta at the time of writing, it is already stable and easy to use either with or without Webware. It looks as though Cheetah will be useful to many web projects, as well as any others that need flexible template substitution of a general nature." Published Jan 8th, 2002.
#end def ################################################################################ #def downloadPageContentsThe most recent stable release was 1.0 on Dec 4, 2005. Don$(apos)t let the version number fool you. Cheetah has been stable, production quality, post-beta code since 2001. All new releases since then (40+) have been almost 100% backwards compatible.
The most recent development release was 2.0rc2 on Jan 13, 2006.
Here$(apos)s the documentation on recent changes.
You can also get the current unreleased development version of Cheetah from our CVS repository.
Cheetah is included in FreeBSD and most major Linux distributions: Gentoo, Fedora, Debian, and Ubuntu among others.
IMPORTANT NOTE TO WINDOWS USERS: If you are using windows and Python 2.4, you should either use one of the .exe releases or grab _namemapper.pyd from the 0.9.17rc1 release and install it wherever your system puts Cheetah/NameMapper.py. This is a compiled copy of the C version of NameMapper (provided by Kevin Dangoor). Using it results in dramatic performance benefits.
#end def ################################################################################ #def examplesPageContentsHere's a very simple example that illustrates some of Cheetah's basic syntax:
#call htmlEncode #raw$title
$client.surname, $client.firstname | $client.email |
Compare this with PSP:
#call htmlEncode #raw<%=title%>
<%=client['surname']%>, <%=client'[firstname']%> | <%=client['email']%> |
See the documentation for more examples.
#end def ################################################################################ #def whousesPageContents
Cheetah is being used in a wide variety of commercial, government, academic, personal, and open-source projects & products. Products built with Cheetah are used by many of the Fortune 500. This page provides selected examples. It is not an exhaustive list. If you use Cheetah and wish to be added here, please send an email to the mailing list.
|
###
|
Cheetah is the work of many volunteers. If you use Cheetah, share your experiences, tricks, customizations, and frustrations. Please join the mailing list.
Help spread the word: blog about it, write articles about it, recommend it to others, etc.
If you think there is a bug in Cheetah, send a message to the email list with the following information:
If you$(apos)re developing a website with Cheetah, please send a link to the email list so we can keep track of Cheetah sites. Also, if you discover new and interesting ways to use Cheetah please share your experience and write a quick tutorial about your technique.
Cheetah is packaged with a regression testing suite that is run with each new release to ensure that everything is working as expected and that recent changes haven$(apos)t broken anything. The test cases are in the Cheetah.Tests module. If you find a reproduceable bug please consider writing a test case that will pass only when the bug is fixed. Send any new test cases to the email list with the subject-line "new test case for Cheetah."
#end def ################################################################################ #def praisePageContents #call $shortPraiseSection $formatQuote("There is no better solution than Cheetah.", 'Wilk') ##http://www.pythonweb.org/projects/webmodules/doc/0.5.3/html_multipage/lib/example-file-web-template-cheetah.html $formatQuote("Cheetah is a powerful, stable and well documented templating system.", 'James Gardner') ##http://keithdevens.com/weblog/archive/2003/Nov/17/Python.Cheetah $formatQuote("Cheetah is very nice. Good code even!", 'Keith Devens') $formatQuote("""People with a strong PHP background absolutely love Cheetah for being Smarty, but much, much better.""", 'Marek Baczynski') ##post on cheetah list about initd.org $formatQuote('i did it in a single night (i _love_ cheetah templates ;)', 'Federico Di Gregorio, developer of psycopg') $formatQuote("""Cheetah seems to be practically the only web templating format with decent taste. On top of that, it doesn't try to limit the programmers with needless restrictions and hoops. ... reddit.com was recently rewritten with Python and Cheetah Templates. The project seems to have gone really well and the former-Lisp developers really enjoyed Cheetah's simple syntax.""", '''Aaron Swartz, co-author of the RSS 1.0 spec''') $formatQuote("""I am using Smarty and I know it very well, but compiled Cheetah Templates with its inheritance approach is much powerful and easier to use than Smarty.""", 'Jaroslaw Zabiello') $formatQuote("""A cheetah template can inherit from a python class, or a cheetah template, and a Python class can inherit from a cheetah template. This brings the full power of OO programming facilities to the templating system, and simply blows away other templating systems.""", 'Mike Meyer') $formatQuote('Love your work guys.', 'Alex Le Dain') $formatQuote("""I'm trying code generation with Cheetah. I have to say it's a pleasure compared to XSLT!""", 'Alex J. Champandard') $formatQuote("""Cheetah has successfully been introduced as a replacement for the overweight XSL Templates for code generation. Despite the power of XSL (and notably XPath expressions), code generation is better suited to Cheetah as templates are much easier to implement and manage.""", '''The FEAR development team''') ##http://www.thescripts.com/forum/post365058-2.html $formatQuote("I'm greatly in favour of Cheetah.", 'Sybren Stuvel') ##http://www.codegeneration.net/tiki-read_article.php?articleId=39 $formatQuote("""I ran across Cheetah, 'a Python-powered template engine and code generator', and haven't looked back since. ... it was a breeze to crank out several templates in a short period of time. In only a few hours a night, over three nights, I was able to learn enough about Python and Cheetah to write a code generator that generates my POJOs, DAOs, and WebWork2 action classes. ... Given my recent experience with Python and Cheetah, I can't imagine an easier way to generate code! """, '''Peter White, in an interview on the "Code Generation Network"''') ##http://blog.kodemaniak.de/archives/10-Python-template-system.html $formatQuote("Cheetah is very powerful and flexible.", 'Carsten Saathoff') ## http://groups.google.com/group/turbogears/tree/browse_frm/thread/bb7a6115ca7028c9/4bd4ca24aa61d75c?rnum=111&q=cheetah+python&_done=%2Fgroup%2Fturbogears%2Fbrowse_frm%2Fthread%2Fbb7a6115ca7028c9%2F7bffb1c3622af7a4%3Flnk%3Dst%26q%3Dcheetah+python%26rnum%3D9%26#doc_7bffb1c3622af7a4 $formatQuote("I've used Cheetah quite a bit and it's a very good package.", 'Kevin Dangoor, lead developer of TurboGears') $formatQuote("""Cheetah is an extremely effective Python-powered template engine that can generate any text-based format. Cheetah's impressive yet simple template language (based on Python) can yield the most complex of documents ... Cheetah is surprisingly simple to use""", c'''Andrew Glover, in an article published on O$(apos)Reilly ONLamp.com''') ##http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/4865ad8dced9d4db/133ada37370deb55?rnum=1&q=cheetah+python&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2F4865ad8dced9d4db%2Ff932e1952225168c%3Flnk%3Dst%26q%3Dcheetah+python%26rnum%3D95%26#doc_f932e1952225168c $formatQuote("Regarding the template engine, the best one I'm aware of is Cheetah.", 'Alessandro Bottoni') $formatQuote("""Just a quick note to say thanks for the work you've put into Cheetah. I had this unholy hack of several perl scripts to do my html templating. After seeing the light and moving to Python, I dreaded rewriting all of that working code. But, after finding Cheetah, I seriously had something working in under an hour that is way better than all of those perl scripts that took me weeks to write. Awesome stuff.""", "Rob McMullen") $formatQuote("""I write to say THANK YOU again! I'm very pleased to see such a friendly community. I appreciate your help! =)""", 'Timur Izhbulatov') $formatQuote("""I hand it to the makers: Cheetah is great stuff. I've used WebMacro for years and this even improves on it. Specifically I like the blocks/functions and the ability to dynamically derive (thanks to python for that""", 'Torsten Rueger') ##http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/eac957ba7c426e30/3ebe6739c8c41752?rnum=31&q=cheetah+python&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Feac957ba7c426e30%2Fa3b9cd8f6cc9e640%3Flnk%3Dst%26q%3Dcheetah+python%26rnum%3D12%26#doc_c166b21577e3ad06 $formatQuote("""But, the problem is PHP itself has so many bad features that I prefer rather Python to PHP. And I like Cheetah's inheritence aproach because it is scales very well for complicated web pages. I can develop internet application much faster using Python (e.g. using application, very cool and pythonic Cherry2) and Cheetah. And because extending templates using OO techniques is tthe feature I like, I would rather choose Cheetach than ZPT, SimleTAL, Nevow and similar solutions.""", 'Jaroslaw Zabiello') ## http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/adbc3058a431f1b8/5b49623e0a8c782c?rnum=31&q=cheetah+template&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2Fadbc3058a431f1b8%2F3a45e7ec2e495bd2%3Flnk%3Dst%26q%3Dcheetah+template%26rnum%3D67%26#doc_3a45e7ec2e495bd2 $formatQuote("""Another great bonus of Spyce is that it can work with Cheetah, the one templating system which I felt like I could live with.""", 'Jonathan P.') ## http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/6ac8c68b6060003e/f3a99fd7ec17d6d5?rnum=1&q=cheetah+template&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2F6ac8c68b6060003e%2F40fe71c3d3ab0bd8%3Flnk%3Dst%26q%3Dcheetah+template%26rnum%3D22%26#doc_40fe71c3d3ab0bd8 $formatQuote( """My graphist and me found it excellent, fast, clear, simple, stable: Pythonic! We found the others engines too verbose ... I use it to generate html, latex and xml""", 'Wilk') $formatQuote("""I was going to try and learn Kid, but I'm in a bit of a hurry, and Cheetah's much closer to what I'm used to.""", 'Dave Benjamin') $formatQuote("""Personally, I prefer to Cheetah Templates to PSP - it plays better in the OO world, and I can use intelligent HTML/XML/SGML editors on the files.""", 'Mike Meyer') #end call #end def ################################################################################ ## Helper methods & content snippets used in multiple places ################################################################################ #def displayLinesAsList(arg): #for ln in arg.splitlines() #set ln = $ln.strip #if not ln #continue #end ifCheetah was originally designed to integrate with Webware for Python, a Python-powered application server, but it can be used with any Python web framework. It is being used with #end if #if includeWebwareInList Webware for Python$sep #end if Aquarium$sep mod_python$sep Quixote$sep CherryPy, TurboGears$sep Django$sep Paste$sep Subway$sep Python Web Modules$sep Spyce$sep Tahchee$sep plain-old-cgi$sep #if includeWrapperText and others. Most of these frameworks provide automatic session, cookie, and user management and can be used with almost any operating-system, web server, or database.
#end if #end def