Custom Tagsets

my $text =<<EOF;
This is [b]some bold text[/b]
This is [i]some italic text[/i]
Thus Spake Andy:

You can also bypass the default TT3 tagset and the TT3 language in its entirety and just do your own thing. This might be your own fully blown template language, or just some simple tag replacement, like the picture tag in the previous example.

The most important difference between TT2 and TT3 is that there is a fundamental split between TT3 the template processing framework/library and TT3 the template language. This split is a necessity so that we can continue to process templates written in the TT2 language using the new TT3 modules. At a deeper level, it's recognition of the fact that there is no "one true template language" that keeps everyone happy all of the time. TT3 is a big step closer to living up to it's name. At the lower levels it provides a toolkit of modules for building template languages, and at the higher level, the glue to bind them all together.

Here's a simple example showing how to bypass the whole TT3 language and use some of the lower level components to parse our own trivial "template" language. Let's say we've got some markup that looks a bit like BBCode and we want to replace all the [b]bold[\b] and [i]italic[\i] tags with their HTML equivalents. (Note that there are plenty of fine modules on CPAN that will parse BBCode so you probably wouldn't want to do it this way. It's a deliberately simple example to illustrate the concepts, but not necessarily best practice)