#47 closed enhancement (fixed)
Include simple text-based templating?
Reported by: | cmlenz | Owned by: | cmlenz |
---|---|---|---|
Priority: | major | Milestone: | 0.3 |
Component: | Template processing | Version: | 0.2 |
Keywords: | Cc: |
Description
As Markup already provides much of the functionality needed for general-purpose templating (not just XML-based templating), it should be possible to reuse this to create a very simple text-based template engine, for those cases where you need to generate plain text, and using a package such as Cheetah may be overkill.
Attachments (5)
Change History (8)
Changed 18 years ago by cmlenz
comment:1 Changed 18 years ago by cmlenz
I've attached a patch that implements a simple text-based template engine (markup.template.TextTemplate) on top of the main Markup template engine (markup.template.Template).
The class reuses a lot of functionality already in place for XML-based templating, such as interpolation and evaluation of expressions, the set of directives (although some make no sense outside of XML), and the general processing logic.
Obviously, this would need more work: for example, there's no position reporting yet.
Changed 18 years ago by cboos
Based on attachment:texttmpl.3.diff and r281, integrates TextTemplate with the TemplateLoader
Changed 18 years ago by cboos
Usage example, for Trac:source:sandbox/markup@3698: conversion of the ticket_notify_email.txt template, plus some adaptations to the Chrome component
comment:2 Changed 18 years ago by cmlenz
- Milestone set to 0.3
- Resolution set to fixed
- Status changed from new to closed
Basic implementation checked in in [292]. Any specific issues/shortcomings of the text templating language should be raised in separate tickets.
comment:3 Changed 18 years ago by cboos
Works great for Trac, see [trac 3730].
Forgot to mention in the commit log there that it requires r300, because of the stripped #end commands.
Template subclass that does basic text-based templating