Template::Stash::XS(3pm)

Template::Stash::XS3pm

High-speed variable stash written in c

Usage

    use Template;
    use Template::Stash::XS;
    my $stash = Template::Stash::XS->new(\%vars);
    my $tt2   = Template->new({ STASH => $stash });

Overview

The Template:Stash::XS module is an implementation of the Template::Stash written in C. The "XS" in the name refers to Perl's XS extension system for interfacing Perl to C code. It works just like the regular Perl implementation of Template::Stash but runs about twice as fast.

The easiest way to use the XS stash is to configure the Template Toolkit to use it by default. You can do this at installation time (when you run "perl Makefile.PL") by answering 'y' to the questions:

    Do you want to build the XS Stash module?      y
    Do you want to use the XS Stash by default?    y

See the INSTALL file distributed with the Template Toolkit for further details on installation.

If you don't elect to use the XS stash by default then you should use the "STASH" configuration item when you create a new Template object. This should reference an XS stash object that you have created manually.

    use Template;
    use Template::Stash::XS;
    my $stash = Template::Stash::XS->new(\%vars);
    my $tt2   = Template->new({ STASH => $stash });

Alternately, you can set the $Template::Config::STASH package variable like so:

    use Template;
    use Template::Config;
    $Template::Config::STASH = 'Template::Stash::XS';
    my $tt2 = Template->new();

The XS stash will then be automatically used.

If you want to use the XS stash by default and don't want to re-install the Template Toolkit, then you can manually modify the "Template/Config.pm" module near line 42 to read:

    $STASH = 'Template::Stash::XS';

Releases

13 releases since Debian 3.0 (Woody); the text changed 11 times.

  1. 3.0
  2. 3.1–4.0
  3. 5.0
  4. 6.0
  5. 7
  6. 8
  7. 9
  8. 10
  9. 11
  10. 12
  11. 13
  12. Arch

Bugs

Please report bugs to the Template Toolkit mailing list [email protected]

Authors

Andy Wardley <[email protected]> <http://wardley.org/>

Doug Steinwand <[email protected]>

From perl-template-toolkit 3.106-2 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.