Simple Template

Movable Type templates aren't too difficult to write, but they can be difficult to read. So I've whipped up another plugin to fix that. Simple Template is a plugin that provides an alternative syntax for Movable Type templates1.


You can download this plugin here:


To install, place the '' file in your Movable Type "plugins" directory. The '' file should be placed in a 'bradchoate' subdirectory underneath your Movable Type "extlib" directory. Your installation should look like this:

  • (mt home)/plugins/
  • (mt home)/extlib/bradchoate/

Refer to the Movable Type documentation for more information regarding plugins.


This plugin provides an alternative format for your Movable Type templates.

Tags made available through this plugin:

  • <MTSimpleTemplate> - The container tag that translates the "simple" template format into a regular Movable Type template.
  • <MTEval> - Container tag that allows you to use embedded expressions for any Movable Type tag.
  • <MTSetVarBlock> - Similar to the SetVar tag, but is a container tag where the value is placed within the tag.


The SimpleTemplate tag should be placed around your entire template so it can process it for the "simple" template syntax it offers.

These attributes are allowed:

  • pragma
    An optional parameter that allows you to define the character(s) used to indicate the Movable Type tag data. The default is '%'.
  • comment
    An optional parameter that allows you to define the character(s) used to indicate comments within the template. The default is '#'.
  • no_build
    If specified, the output from this tag will be the Movable Type template code it produces. Normally, the output is the compiled result of the template.


Here's a very simple Movable Type template:

<MTIfEntryExtended>Extended text: <$MTEntryMore$></MTIfEntryExtended>

Here is the same thing in "simple" format:

% EntryBody
% EntryIfExtended:
Extended text: ${EntryMore}
% :EntryIfExtended

Note that there are two forms you can use to produce MT tags:

  1. Pragma format: a line starting with the '%' character (or you can customize this using the 'pragma' attribute of the SimpleTemplate tag) is seen as a Movable Type instruction. Exactly one MT tag may be produced per pragma. If the pragma line ends with ":" (or ``{'', ``('', ``['') it is considered an open MT tag. If the pragma starts with ":" (or "}", ")", "]") it is considered a closing tag.
  2. Inline format: ${Variable attribute="value"}
    This is a simple way to express: <$MTVariable attribute="value"$>

Any Movable Type tags can be used with this -- you would just refer to them without the usual "MT" prefix.

Here's some more examples:

% Comments:
<div class="comments-body">
% CommentBody
<span class="comments-post">Posted by: ${CommentAuthorLink spam_protect="1"}
at ${CommentDate}</span>
% :Comments

This demonstrates line-continuation with Simple Templates. If the pragma ends with "\\" and the next line is a pragma line, then it gets concatenated together:

% EntryDate \
%   format="%Y-%m-%dT%H:%M:%S"


<$MTEntryDate format="%Y-%m-%dT%H:%M:%S"$>

Container tags should be written like this:

% EntryIfExtended:

Something something...

% :EntryIfExtended

or this:

% EntryIfExtended {

Something something...

% } EntryIfExtended

or this:

% EntryIfExtended {

Something something...

% }

Non-container tags (like <$MTEntryBody$>) can be written like this:

% EntryBody

or this:


Comments may be included (default comment character is '#') but the comment character must be at the start of the line (no spaces prior to it):

# This is a comment.


Evaluates embedded expressions within any arbitrary MT tag.


  • _tag
    If specified, the Eval tag functions as a proxy for the tag identified. If unspecified, the Eval tag expects a single Movable Type tag to be enclosed within the Eval tag.

For global filters, you can pass attribute names like this:

<MTEval _tag="GetVar" name="something" 001lower_case="1" 002upper_case="1" />

This will cause the filters to be applied in the order they are numbered.
You can even duplicate the global filter attribute name/value pairs,
combining the operations in any order you wish.


<MTSetVar name="lastn" value="5">
<MTEval _tag="Entries" lastn="[MTGetVar name='lastn']">
  (Entry tags go here)


<MTSetVar name="lastn" value="5">
<MTEval><MTEntries lastn="[MTGetVar name='lastn']">
  (Entry tags go here)

You can also use it for simple MT tags (non-container tags):

<MTSetVar name="lastn" value="5">
<MTSetVar name="variable" value="lastn">
<MTEval _tag="GetVar" name="[MTGetVar name='variable']" />


Allows you to define a complex string (multi-line, with tags and even Movable Type tags) for a variable.

  • name
    Name of variable to assign.


<MTSetVarBlock name="my_info">
<p>This is a very long block of text that
I'm using to describe myself.</p>

<p>And so forth</p>


Released under the MIT license.


  • 1.21: Bugfix to wrapper <MTEval> support.
  • 1.2: Added support for specifying multiple global filter attribute name/value pairs. They are also processed in the order specified.
    Made the = sign following the attribute names optional.
    Renamed the "no_compile" attribute to "no_build" (more accurate in
  • 1.1: Added Eval and SetVarBlock tags. Implemented dynamic replacement of ${...} expressions within MT attributes.
    Defined default attribute names for many tags that only have a single attribute or have 1 required attribute that drives their function.
  • 1.0: Initial release.

1 Personally, I like it -- but the "simpler" aspect of this is my opinion of course, not necessarily yours.


TrackBack URL for this entry:

Listed below are links to weblogs that reference Simple Template:

» Simple Template from Tech-Weblog by Christoph C. Cemper
Brad Choate created Simple Template because Movable Type templates aren?t too difficult to write, but they can be difficult to read. So he has whipped up another plugin to fix that. Simple Template is a plugin that provides an alternative... [Read More]

» SimpleTemplates from MT Plugin Directory
... [Read More]

» Pluggin' the Plugins from JayAllen - The Daily Journey
Brad Choate comes up with yet another great plugin: Simple Template ( page) Movable Type templates aren’t too difficult to [Read More]

» MT Plugins Installed from Technology Updates
The following MovableType plugins were installed: From Brad Choate IncludeEx - Improves on MT’s Include tag by processing the included file for MT tags. MTAuthors - This plugin allows you to list the authors for your blog. You can also... [Read More]

» Sitewide RSS from ETC. Indulging my inner geek
Brad Choate: Sitewide RSS - as a companion to "Doing Your Whole Site in Movable Type", a feed for your... [Read More]

» Simple Template plugin from Perceptions
Simple Template plug in for MT... [Read More]

» Hero of the Day from wuermldotnet
Er ist heute zu meinem "Hero of the Day" gewählt worden. Stundenlang habe ich versucht, folgendes Szenario mit MovableType umzusetzen: In meinem Category Archive Template will ich Informationen einer bestimmten Kategorie (nämlich derjenigen, welche ger... [Read More]

» New archive format from Socialblunders
Many thanks to Elise and her site Learning Movable Type for yet another useful tutorial, this time on how to set up a yearly archive display. Now, with a little code and a few plug-ins, I can tame the beast... [Read More]


Jesper said:

"Initial release" my ass ;)

Jay Allen said:

Nice job, Brad. I am particularly excited about the comments. Yes, I know about the plugin which provides for comments, but you have to put a set of tags around it...

I haven't yet put the plugin to use but if I understand it correctly, the plugin translates the template on-the-fly and then produces the page meaning that you never see the normal MT tags at any point. This is bad if only because (for debugging or demonstration purposes) it makes it harder for a user to display his/her template for public consumption.

If used in conjunction, would the showtemplates or template plugins show the simpletemplate form or the MT-translated form? If the latter, then nevermind.

...although it might be nice to have an outputTemplateFile attribute that will write out the translated MT template to the file specified as its argument...

Anyway, good work, as always!

Jay Allen said:

I am an idiot... The no_compile attribute does this, does it not? (slaps forehead) REALLY nice job, Brad..


This article was published on July 19, 2003 7:38 AM.

The article previously posted was Doing your whole site with MT.

The next article is Mozilla.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type