which passes the body of an entry (post) through one of my Perl routines, and embeds the result in the output page.<MTPerl> require "mutate.pl"; mutate("<$MTEntryBody$>"); </MTPerl>
Adding an <MTPerl> tag ended up being really easy, requiring two modifications to MT::Template::Context.pm
At the bottom of init_default_handlers, add $ctx->register_handler(Perl => [ \&_hdlr_perl, 1 ]); Then add the following near the end of the package:
Voila! You've voided your MoveableType warranty, and can do incredibly evil things with embedded Perl.sub _hdlr_perl { my($ctx, $args) = @_; my $tokens = $ctx->stash('tokens'); my $builder = $ctx->stash('builder'); my $res = ''; defined(my $out = $builder->build($ctx, $tokens)) or return $ctx->error($builder->errstr); $res = eval $out; return $@ if $@; $res; }
|
---|