Edgewall Software

Opened 17 years ago

Closed 17 years ago

Last modified 15 years ago

#115 closed enhancement (fixed)

[PATCH] The text template language needs a #include

Reported by: alastair@… Owned by: cmlenz
Priority: major Milestone: 0.5
Component: General Version: 0.4
Keywords: Cc:

Description

The text template language needs a #include statement. The XML language gets away without one because it supports XInclude via a filter, but the text templates don't have anything at the moment.

I've attached a simple implementation that gives us a #include statement that works as follows:

You can include text from other text templates in your output by doing

#include some-other-template.txt

It works in a similar way to the XInclude feature of the XML template language, so you can also do

#include ../foo/bar.txt

and the like.

The code I've written replaces the entire line the #include is on with the results of generating the other template; there's no way to just include a string in the middle of a line (for example).

Attachments (2)

genshi-textinclude.diff (4.3 KB) - added by alastair@… 17 years ago.
Text template language include statement patch
textinclude.diff (8.9 KB) - added by cmlenz 17 years ago.
Alternative patch

Download all attachments as: .zip

Change History (5)

Changed 17 years ago by alastair@…

Text template language include statement patch

Changed 17 years ago by cmlenz

Alternative patch

comment:1 Changed 17 years ago by cmlenz

I've attached an alternative implementation that reuses the INCLUDE event kind already used by markup templates. Does this work for you, too?

comment:2 Changed 17 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Patch applied in [575]. Thanks!

comment:3 Changed 17 years ago by alastair@…

Yes, that works nicely, thanks; the test I added passes and my app is sending e-mail OK (which is what I'm using this feature for). My patch was originally based on Genshi-0.3, since that's what I was using before, but I updated to the latest version when I noticed 0.4 on the site, so I didn't have the INCLUDE event. At least, I don't remember seeing it.

Note: See TracTickets for help on using tickets.