Edgewall Software

Ticket #47 (closed enhancement: fixed)

Opened 8 years ago

Last modified 8 years ago

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

texttmpl.diff Download (2.8 KB) - added by cmlenz 8 years ago.
Template subclass that does basic text-based templating
texttmpl.2.diff Download (4.3 KB) - added by cmlenz 8 years ago.
Updated to include position info
texttmpl.3.diff Download (3.6 KB) - added by cmlenz 8 years ago.
Bugfix: don't ignore last text partition
texttmpl.4.diff Download (4.4 KB) - added by cboos 8 years ago.
Based on attachment:texttmpl.3.diff Download and r281, integrates TextTemplate with the TemplateLoader
trac-ticket_notify_mail-r3697.diff Download (4.7 KB) - added by cboos 8 years ago.
Usage example, for  Trac:source:sandbox/markup@3698: conversion of the ticket_notify_email.txt template, plus some adaptations to the Chrome component

Change History

Changed 8 years ago by cmlenz

Template subclass that does basic text-based templating

Changed 8 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 8 years ago by cmlenz

Updated to include position info

Changed 8 years ago by cmlenz

Bugfix: don't ignore last text partition

Changed 8 years ago by cboos

Based on attachment:texttmpl.3.diff Download and r281, integrates TextTemplate with the TemplateLoader

Changed 8 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

Changed 8 years ago by cmlenz

  • status changed from new to closed
  • resolution set to fixed
  • milestone set to 0.3

Basic implementation checked in in [292]. Any specific issues/shortcomings of the text templating language should be raised in separate tickets.

Changed 8 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.

Add/Change #47 (Include simple text-based templating?)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.