See, this is what I would consider to be a bad design decision. This completely ties the templating system into HTML and with different syntax for different output. What happens if you want to use your template for something other than HTML and need a different type of escaping? What if you want to escape your HTML in different ways?
Agreed. I've in TODO list this feature:
- move parser from POWER::iCGI module into separate POWER::Template module and make it configurable a-la (shown interface is just an example of needed features, not proposed module interface):
my $t = POWER::Template->new();
# example configuration to simulate POWER::iCGI:
$t->text('@~', '~@', \&Enc);
$t->text('^~', '~^', \&EncUri);
$t->text('#~', '~#', undef);
This way parser become 100% configurable, will have same 30 lines of code or even less, and my templates will use "tags" and escaping/converting features suitable for each format - one in html template, other in email templates, etc.
UPDATE: And don't forget, I don't write these comments to compare my template system to yours, I just wanna prove this task is much simpler than you affirm.