Using a Template Output Transformation Callback
The final callback that is invoked for any given template is the template_output callback which can be used to modify the final output or HTML a template produces. The callback also makes available through its input parameters other data that can be used by the business logic of your callback.
Input Parameters
- $cb - a reference to the current
MT::Callbackobject handling this event. - $app - a reference to the
MT::App::CMSobject processing this request. - $out - a reference to the final output from the template.
- $param - This is the form parameters submitted or passed to the current screen being rendered or modified
- $tmpl - the actual MT::Template object representing the current page
The $param and $tmpl input parameters are made available to provide important context for your callback. However, because the template has already been compiled and rendered into HTML, modifying these input parameters will have no bearing on the final output of your template.
Sample Code
sub xfrm {
my $plugin = shift;
my ($cb, $app, $out, $param, $tmpl) = @_;
$$out =~ /cat/dog/mgi;
}