Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I just realized I didn't answer the question directly. Here is a solution doing what you asked for. It does use some of the deep internals of the Alloy op tree though (so beware). But with a little more tweaking it would be a fine precommit hook - and then you could keep using your existing template system.

#!/usr/bin/env perl use strict; use warnings; use Template::Alloy; my $file = \ << 'EOF'; [% foo_is_not_filtered %] [% foo_is_filtered | html %] [% IF foo %] [% bar %] [% END %] [% foo_is_none | none %] [% BLOCK some_block %] [% block_var %] [% END %] EOF my $ta = Template::Alloy->new; my $doc = $ta->load_template($file); my $checker; $checker = sub { my $ref = shift; return if ! ref $ref; foreach my $node (@$ref) { next if ! ref $node; if ($node->[0] eq 'GET' && $node->[1] =~ /^\d+/) { my $expr = $node->[3]; next if ! ref $expr; my $info = $ta->node_info($node); if (@$expr < 5 || $expr->[-3] ne '|') { print "File \"$info->{'file'}\" line $info->{'line'}: +No filtering ($info->{'text'})\n"; } else { next if $expr->[-2] ne 'none'; # comment out to note e +very filter print "File \"$info->{'file'}\" line $info->{'line'}: +Used $expr->[-2] filter ($info->{'text'})\n"; } } $checker->($_) for @$node; } }; local $ta->{'_component'} = $doc; $checker->($doc->{'_tree'}); File "input text" line 8: No filtering (block_var) File "input text" line 1: No filtering (foo_is_not_filtered) File "input text" line 4: No filtering (bar) File "input text" line 6: Used none filter (foo_is_none | none)

Update: If there was demand for it, I could certainly look into making this more of a first class method as part of the standard Template::Alloy distribution. Then it could more easily be reused by anybody speaking TT dialects using any TT or TA module.
my @a=qw(random brilliant braindead); print $a[rand(@a)];

In reply to Re: How to test all TT2 tags are escaped. by Rhandom
in thread How to test all TT2 tags are escaped. by chrestomanci

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (2)
    As of 2018-03-24 08:26 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (297 votes). Check out past polls.