[Templates-cvs] cvs commit: Template2/docsrc/src/Modules/Template/Stash XS.tt2
cvs@template-toolkit.org
cvs@template-toolkit.org
cvs 06/05/26 11:41:02
Modified: docsrc/src/Modules/Template/Stash XS.tt2
Log:
Updated XS stash docs
Revision Changes Path
1.3 +32 -22 Template2/docsrc/src/Modules/Template/Stash/XS.tt2
Index: XS.tt2
===================================================================
RCS file: /template-toolkit/Template2/docsrc/src/Modules/Template/Stash/XS.tt2,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XS.tt2 2006/02/02 11:46:07 1.2
+++ XS.tt2 2006/05/26 11:41:02 1.3
@@ -10,40 +10,50 @@
=head1 DESCRIPTION
-This module loads the XS version of Template::Stash::XS. It should
-behave very much like the old one, but run about twice as fast.
+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.
-Only a few methods (such as get and set) have been implemented in XS.
-The others are inherited from Template::Stash.
+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 C<perl Makefile.PL>) by answering 'y' to the questions:
-=head1 NOTE
+ Do you want to build the XS Stash module? y
+ Do you want to use the XS Stash by default? y
-To always use the XS version of Stash, modify the Template/Config.pm
-module near line 45:
+See the F<INSTALL> file distributed with the Template Toolkit for further
+details on installation.
- $STASH = 'Template::Stash::XS';
+If you don't elect to use the XS stash by default then you should use
+the C<STASH> configuration item when you create a new Template object.
+This should reference an XS stash object that you have created
+manually.
-If you make this change, then there is no need to explicitly create
-an instance of Template::Stash::XS as seen in the SYNOPSIS above. Just
-use Template as normal.
+ use Template;
+ use Template::Stash::XS;
-Alternatively, in your code add this line before creating a Template
-object:
+ my $stash = Template::Stash::XS->new(\%vars);
+ my $tt2 = Template->new({ STASH => $stash });
- $Template::Config::STASH = 'Template::Stash::XS';
+Alternately, you can set the C<$Template::Config::STASH> package
+variable like so:
-To use the original, pure-perl version restore this line in
-Template/Config.pm:
+ use Template;
+ use Template::Config;
- $STASH = 'Template::Stash';
+ $Template::Config::STASH = 'Template::Stash::XS';
-Or in your code:
+ my $tt2 = Template->new();
- $Template::Config::STASH = 'Template::Stash';
+The XS stash will then be automatically used.
-You can elect to have this performed once for you at installation
-time by answering 'y' or 'n' to the question that asks if you want
-to make the XS Stash the default.
+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
+C<Template/Config.pm> module near line 42 to read:
+
+ $STASH = 'Template::Stash::XS';
=head1 BUGS