Welcome, Guest :: Blog Home | Login | Register

Articles By Tag:
Template::Plugin::HighlightPerl v0.03

2008-04-25 03:32:19 Tags: perl template toolkit cpan

Version 0.03 is now available on CPAN. This version fixes a bug where no line breaks were added when no code tags are used. This version is stable and probably will be the last update for a while.

Don't forget to restart httpd service after upgrade. ;)

[ Comments (0) ]




Template::Plugin::HighlightPerl

2008-04-16 21:09:57 Tags: perl template toolkit cpan

CPAN Link:

http://search.cpan.org/perldoc?Template::Plugin::HighlightPerl

I just uploaded my new module to CPAN. The module is a TT2 (Template Toolkit) filter which can be used for blog posts where Perl code is to be shown. It is a sort of wrapper for the Syntax::Highlight::Perl module and is used within the template file (.tt2) as a filter. I say "sort of" because it is really much more than that. It will "dynamically" highlight all perl code based on syntax and includes a css div classes for custom formatting. It also can be used to format non-perl code by using a different set of tags.

Here's a sample of the dynamically generated syntax highlighting.

Perl Code:
package Template::Plugin::HighlightPerl;

use Syntax::Highlight::Perl;
use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
use strict;

our $VERSION = '0.01';

sub init {
    my $self = shift;
    my $name = $self->{ _CONFIG }->{ name } || 'highlight_perl';
    $self->install_filter($name);
    return $self;
}


[ Comments (0) ]