Adding a Simple Template Tag
Now that you have created your first Movable Type configuration directive, we need a way to display it’s assigned value on a blog or web site. Hopefully you will find accomplishing this just as simple as before, however, this time we will need to actually create some code.
A Word About Perl
As always, let’s start with the YAML you will need to define your first template tag:
name: Good for Nothing Plugin for Movable Type
author_name: Your Name Here
description: This plugin is an example plugin for Movable Type.
There are a couple of things going on here. First the ‘function’ key defines the type of tag we are creating (we will review the other types of tags later in this manual). A
function template tag simply outputs text.
The child element of
MyImageURL, which defines the name of your template tag. The value of
MyImageURL is a reference to a subroutine defined elsewhere in your plugin. When you include this template tag on your web site, Movable Type will invoke the subroutine called “tag” located in the module “Good4Nothing::Plugin” defined by the plugin called “$Good4Nothing” (corresponding to the ‘key’ used when registering your plugin).
Finally, Movable Type will support multiple case-insensitive syntaxes in referencing the tag name you create. For example, all of the follow are valid ways to refer to the template tag defined above:
Ok, take a deep breath, it is time for some code.