Help-Site Computer Manuals
  Algorithms & Data Structures   Programming Languages   Revision Control
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

provides a Template Toolkit filter for Chump like syntax

Template::Plugin::Chump - provides a Template Toolkit filter for Chump like syntax


Template::Plugin::Chump - provides a Template Toolkit filter for Chump like syntax


        [% USE Chump %]



        [% FILTER chump %]

        This will get turned into a clickable link

        This will turn the word 'foo' into a link to


        This will get turned into an image link 


        This will get turned into an inline image with the label 'bar'


    This will get turned into an image with the label 'bar' which 

    is a link to


        [% END %]

        And this will do what you expect

        [% somevar FILTER chump %]

        [% Chump.new_type('equal','=', subref,'rege+xp') %]

        [% FILTER chump %]


        [% END %]

        the subroutine subref will now be called for all links 

    of the format =[<stuff>]

        [% FILTER chump( {links=>0}) %]

        links won't be parsed so this ...


        will remain as is

        [% END %]       




Alternatively you can pass in a Text::Chump object and use that.

        [% USE Chump({ chump => my_chump_object }) %]


Chump is a simplified markup language that allows for simple markup of text to include urls, links and inline images.

Chump is based on an original idea by Bijan Parsia who wrote a bot named DiaWebLogBot in Squeak for the Monkeyfist Daily Churn. Subsequently Useful Inc. ``stole all his good ideas'' for their own IRC bot.

The bot is available from and the original page that uses this form of markup is

From there the syntax was adopted by various other projects where more complex solutions such as Text::WikiFormat or HTML::FromText aren't needed or don't have the right features and an extensible parser was written because that's what good little programmers do.

Text::Chump is a surprisingly (too the author if not anyone else), flexible and powerful Chump parser. From humble beginnings it has evolved to allow installable handlers and new types. All with a nice simple interface.

Template::Plugin::Chump brings that interface to Template::Toolkit.

It's probably useful for allowing users to enter text which is HTML safe (i.e no nasty cross site scripting bugs) but still allows them to provide links and inline images.


Template::Plugin::Chump can handle the same options as Text::Chump.

Just pass them in either when loading the plugin or filtering with it.

        [% USE Chump({ urls=>0 }) %]

        [% FILTER chump({ urls=>1 }) %]

        some text


        [% END %]

Like that.

You can also call the new_type and install methods from Text::Chump using

        [% Chump.install(...) %]


        [% Chump.new_type(...) %]

the code ref you pass in must be a variable in the vars hash ref you pass into Template::Toolkit. Remember, because sub refs get called automatically you need something which returns a sub ref.

So, in your CGI script you need something like

        $vars->{uc} = sub { return sub { return uc $_[1] } };

        # stuff

        $tt->process($template, $vars);

And then in your template you do

        [% Chump.install('equal', '=', uc) %]

        [% FILTER chump %]


                This will give FOO

        [% END %]

Que convenient :)

Alternatively you can pass in a fully formed Text::Chump object as a template var and use that instead inorder to more cleanly seperate code from presentation.

        sub uc { return uc $_[1] };

        my $tc = Text::Chump->new();




        $tt->process($template, { my_chump => $tc });

And then in the template

        [% USE Chump ( { chump => my_chump } ) %]

        [% FILTER chump %]


                This will give FOO

        [% END %]


Simon Wistow <>


(C)opyright 2003, Simon Wistow

Distributed under the same terms as Perl itself.

This software is under no warranty whatsoever and will probably ruin your life, kill your friends, burn down your house and bring about the apocalypse.


None known.


the Text::Chump manpage, the Template::Plugin::Filter manpage