[Templates-cvs] cvs commit: TT3/lib/Template Constants.pm
cvs@template-toolkit.org
cvs@template-toolkit.org
Mon, 08 Nov 2004 19:05:33 +0000
cvs 04/11/08 19:05:33
Added: lib/Template Constants.pm
Log:
* added Template::Constants
Revision Changes Path
1.1 TT3/lib/Template/Constants.pm
Index: Constants.pm
===================================================================
#============================================================= -*-perl-*-
#
# Template::Constants
#
# DESCRIPTION
# Defines constants used by other Template modules.
#
# AUTHOR
# Andy Wardley <abw@wardley.org>
#
# COPYRIGHT
# Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
# Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# REVISION
# $Id: Constants.pm,v 1.1 2004/11/08 19:05:33 abw Exp $
#
#========================================================================
package Template::Constants;
require Exporter;
use strict;
use warnings;
use base qw( Exporter );
use vars qw( $VERSION @EXPORT_OK %EXPORT_TAGS );
use vars qw( @CHOMP @ACTIONS );
$VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
# CHOMP constants for PRE_CHOMP and POST_CHOMP
use constant CHOMP_NONE => 0; # do not remove whitespace
use constant CHOMP_REMOVE => 1; # remove whitespace
use constant CHOMP_COLLAPSE => 2; # collapse whitespace to single space
@CHOMP = qw( CHOMP_NONE CHOMP_REMOVE CHOMP_COLLAPSE );
# parse actions
use constant ERROR => undef; # a parse error
use constant DECLINE => 0; # decline a parse event
use constant ACCEPT => 1; # accept a parse event
use constant EXPAND => 2; # expand handler chain for nested content
use constant EXTEND => 3; # extend current handler chain for next block
use constant REDUCE => 4; # reduce chain after nested content
@ACTIONS = qw( ERROR DECLINE ACCEPT EXPAND EXTEND REDUCE );
@EXPORT_OK = ( @CHOMP, @ACTIONS );
%EXPORT_TAGS = (
'all' => [ @EXPORT_OK ],
'chomp' => [ @CHOMP ],
'actions' => [ @ACTIONS ],
);
1;
__END__
=head1 NAME
Template::Constants - defines constants for other TT modules
=head1 SYNOPSIS
use Template::Constants;
# TODO
=head1 DESCRIPTION
This module defines a number of constants used by other modules in the
Template Toolkit. They can be used by specifying the
Template::Constants package explicitly as part of the name:
use Template::Constants;
$chomp = Template::Constants::CHOMP_REMOVE;
Constants may be imported into the caller's namespace by naming them as
options to the C<use Template::Constants> statement:
use Template::Constants qw( CHOMP_REMOVE );
$chomp = CHOMP_REMOVE;
Alternatively, one of the tagset identifiers may be specified
to import different sets of constants.
use Template::Constants qw( :chomp );
$chomp = CHOMP_REMOVE;
=head1 EXPORTABLE TAG SETS
The following tag sets and associated constants are defined:
:chomp # constants relating to whitespace chomping
CHOMP_NONE
CHOMP_REMOVE
CHOMP_COLLAPSE
:all # all the above constants.
=head1 AUTHOR
Andy Wardley E<lt>abw@wardley.orgE<gt>
=head1 VERSION
$Revision: 1.1 $
=head1 COPYRIGHT
Copyright (C) 1996-2004 Andy Wardley. All Rights Reserved.
Copyright (C) 1998-2002 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 SEE ALSO
See L<Exporter> for more information on exporting variables.
=cut
# Local Variables:
# mode: perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4: