Template::Alloy::XS - XS version of key parts of Template::Alloy


Template-Alloy-XS documentation Contained in the Template-Alloy-XS distribution.

Index


Code Index:

NAME

Top

Template::Alloy::XS - XS version of key parts of Template::Alloy

SYNOPSIS

Top

    use Template::Alloy::XS;

    my $obj = Template::Alloy::XS->new;

    # see the Template::Alloy documentation

DESCRIPTION

Top

This module allows key portions of the Template::Alloy module to run in XS.

All of the methods of Template::Alloy are available. All configuration parameters, and all output should be the same. You should be able to use this package directly in place of Template::Alloy.

BUGS/TODO

Top

Add play_variable

With the compile_perl option we added play_variable which is a partially resolved variable mapper - more closely associated with Template::Stash's get method. We need to recreate the method here.

Memory leak

The use of FILTER aliases causes a memory leak in a cached environment. The following is an example of a construct that can cause the leak.

  [% n=1; n FILTER echo=repeat(2); n FILTER echo %]

Anybody with input or insight into fixing the code is welcome to submit a patch :).

undefined_any

The XS version doesn't call undefined_any when play_expr finds an undefined value. It needs to.

AUTHOR

Top

Paul Seamons, <paul@seamons.com>

LICENSE

Top

This module may be distributed under the same terms as Perl itself.


Template-Alloy-XS documentation Contained in the Template-Alloy-XS distribution.
package Template::Alloy::XS;

use strict;
use warnings;
use XSLoader;
use v5.8.0;
use Template::Alloy 1.002;
use base qw(Template::Alloy);

our $VERSION = '1.003';
XSLoader::load('Template::Alloy::XS', $VERSION);

### method used for debugging XS
sub __dump_any {
    my ($self, $data) = @_;
    require Data::Dumper;
    print Data::Dumper::Dumper($data);
}

### this is here because I don't know how to call
### builtins from XS - anybody know how?
sub __lc { lc $_[0] }

sub play_tree {
    my $self = shift;
    return $self->stream_tree(@_) if $self->{'STREAM'};
    require Template::Alloy::Play;
    $self->play_tree_xs(@_);
}

1;

__END__