I'm in the process of building a web application using cherrypy.
What template technology do you recommend I use?
I'm in the process of building a web application using cherrypy.
What template technology do you recommend I use?
Do you mean View in MVC? I recommend you very nice template engine Jinja2.
If you mean a templating engine, I've had some success using mako with cherrypy. They just seem to play nicely together.
Mako is extremely easy to get started with and customize, which is, I assume, also two of your major reasons for choosing cherrypy. The cherrypy official tutorial also uses mako, and you can see a simple sample application there.
Do you mean View in MVC? I recommend you very nice template engine Jinja2.
I like Cheetah.
I like Genshi.
One reason that I like it is simply that the XML syntax looks much cleaner to me when mixed with HTML versus the text-level syntax of the other popular templating engines. For example, it's nice to be able to stick a py:for attribute on to output a table versus nesting messy #if or whatever lines.
Another reason is that because it's based on XML and treats your HTML as XML, it guarantees that your markup is syntactically correct -- i.e. that tags are closed and properly nested, special characters are properly escaped, etc.. Other templating engines will simply treat your HTML as text and output whatever you give it without the extra santity checks.
The main disadvantage of Genshi is that it is much slower than the faster text-based engines. However, its performance should be good enough for most sites. Unless you have a site that has a special need to render text/HTML at a super fast rate, the readability and syntax checking that Genshi provides probably outweigh the performance hit.
A Zen master would probably answer: "Yes".
If you are building a web interface I would choose an engine that provides readable markup templates such as Genshi does.
If you are building a rest server and need to return other types of data I would go with one of the more text oriented engines such as Cheetah or Mako.
For building HTML pages I prefer Genshi over Cheetah or Mako even if it's quite a bit slower. When returning JSON I rather prefer the faster text-based engines.
And because Cherrypy is engine agnostic you can use both if you need it.
There is also Genshi Their tutorial is based on using cherrypy
© 2022 - 2024 — McMap. All rights reserved.