Scratchpad

Template Engines

As an initial proposal i would suggest starting out with Genshi as a template engine. It's quite clean and lean in it's implementation and according to AlexanderSchremmer the genshi guys seem to be working on additional speedups1. There are many other template engines out there, some with similar approaches. Some comments from the community on what style of engine they would prefer would be really nice here. I have a small list of engines i already worked with below, each one with a small comment according to my experience:

Genshi: It's mostly pure XML (has a more text-style parser), stream-driven, and very easy to extend through the means of stream filters and output encoders (could be useful for the different output-formats of MoinMoin). The markup for common templating operations consists of a small set of directives, stated as tag attributes in a special XML namespace. Everything that's inserted on rendering the template is automagically HTML-escaped (in the HTML output encoders), so one doesn't has to worry much about that.

Myghty: Myghty uses special linestarts ('%' if i remember correctly) and PHP-style markup for embedding control code into the templates. The code can be pretty anything python. Output encoding for the web has to be done manually. It's a flexible approach, but the templates will often fail for validation in html/xhtml scenarios.

Kid: There is not much to say here, because basically it's a predecessor to Genshi. The genshi guys wanted a speedier version of Kid with a cleaner separation of different aspects of templating. So i just include it for reference, because i encountered it after Myghty and before Genshi.

Other engines, i heard about but didn't take a look at myself include Mako, which seems to be a successor to Myghty, and Cheetah, which i currently do not know enough about to state an impression.

See also TemplateSystems

Templating in MoinMoin

Currently themes for MoinMoin are classes that implement a whole lot of methods that return HTML-snippets for different parts of the page (navigation, headers, footers, etc.). The methods get called by many parts of MoinMoin, though for representation most of those calls come from the Page module and class.

The first idea behind this SoC-project was to try out template-engines by creating a new MoinMoin theme leveraging the power of a template engine beneath it's surface. Although that would be a nice starting point, i currently doubt that there will be a real benefit here. Because of the call structure of theme code (from all over place, you remember?) and the fact that rendering out partials of templates is not intendend in most of these engines (apart from Genshi perhaps), the user/html-coder of this theme would end up creating several files, each containing little html snippets.

On the other hand, putting templates directly into MoinMoin will require major changes to the core codebase, especially the Page-related modules and classes, which currently drive output.

So currently i am mostly thinking about, if i should start with the theme-based approach or start aiming directly at the codebase, since this is going to be crucial for templating anyway?

CSS Frameworks

  1. No, they are not - nobody really knows how to speed it up significantly, the task would be hard enough for a bachelor thesis -- AlexanderSchremmer (1)

MoinMoin: FlorianKrupicka/SOC2007/Ideas (last edited 2008-05-03 13:58:49 by FlorianKrupicka)