# MTSanitizeSpec 0.1 ($Date: 2003/04/09 18:43:52 $) by Alexei Kosut # # Show the HTML tags currently allowed on the site: # # <<$MTSanitizeSpecTag>> use MT 2.6; use MT::Template::Context; use MT::Sanitize; use strict; use warnings; MT::Template::Context->add_container_tag(SanitizeSpec => sub { my ($ctx, $args) = @_; my $builder = $ctx->stash('builder'); my $tokens = $ctx->stash('tokens'); # Use the same rules as MT::Context::Template, except get the spec # from the 'spec' attribute instead of 'sanitize' my $spec = $args->{'spec'} || $ctx->stash('blog')->sanitize_spec || MT::ConfigMgr->instance->GlobalSanitizeSpec; my $parsed_spec = MT::Sanitize->parse_spec($spec); my $res = ''; foreach my $tag (sort keys %{$parsed_spec->{ok}}) { $ctx->stash('sanitize_spec_tag', $tag); defined (my $out = $builder->build($ctx, $tokens)) or return $ctx->error($ctx->errstr); $res .= $out; } return $res; }); MT::Template::Context->add_tag(SanitizeSpecTag => sub { my $tag = $_[0]->stash('sanitize_spec_tag') or return $_[0]->error("Tag called without SanitizeSpec in context"); return $tag; });