Bug 26922: Regression tests
[koha.git] / C4 / TmplTokenType.pm
blobc8a5c96e890c81ba74cbf617103d3c15504f706a
1 package C4::TmplTokenType;
3 # Copyright 2011 Tamil
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
21 require Exporter;
23 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
25 ###############################################################################
27 =head1 NAME
29 C4::TmplTokenType.pm - Types of TmplToken objects
31 =head1 DESCRIPTION
33 This is a Java-style "safe enum" singleton class for types of TmplToken objects.
34 The predefined constants are
36 =cut
38 ###############################################################################
41 @ISA = qw(Exporter);
42 @EXPORT_OK = qw(
43 &TEXT
44 &TEXT_PARAMETRIZED
45 &CDATA
46 &TAG
47 &DECL
48 &PI
49 &DIRECTIVE
50 &COMMENT
51 &UNKNOWN
54 ###############################################################################
56 use vars qw( $_text $_text_parametrized $_cdata
57 $_tag $_decl $_pi $_directive $_comment $_null $_unknown );
59 BEGIN {
60 my $new = sub {
61 my $this = 'C4::TmplTokenType';#shift;
62 my $class = ref($this) || $this;
63 my $self = {};
64 bless $self, $class;
65 ($self->{'id'}, $self->{'name'}, $self->{'desc'}) = @_;
66 return $self;
68 $_text = &$new(0, 'TEXT');
69 $_text_parametrized = &$new(8, 'TEXT-PARAMETRIZED');
70 $_cdata = &$new(1, 'CDATA');
71 $_tag = &$new(2, 'TAG');
72 $_decl = &$new(3, 'DECL');
73 $_pi = &$new(4, 'PI');
74 $_directive = &$new(5, 'DIRECTIVE');
75 $_comment = &$new(6, 'COMMENT');
76 $_unknown = &$new(7, 'UNKNOWN');
79 sub to_string {
80 my $this = shift;
81 return $this->{'name'}
84 sub TEXT { $_text }
85 sub TEXT_PARAMETRIZED { $_text_parametrized }
86 sub CDATA { $_cdata }
87 sub TAG { $_tag }
88 sub DECL { $_decl }
89 sub PI { $_pi }
90 sub DIRECTIVE { $_directive }
91 sub COMMENT { $_comment }
92 sub UNKNOWN { $_unknown }
94 ###############################################################################
96 =over
98 =item TEXT
100 normal text (#text in the DTD)
102 =item TEXT_PARAMETRIZED
104 parametrized normal text
105 (result of simple recognition of text interspersed with <TMPL_VAR> directives;
106 this has to be explicitly enabled in the scanner)
108 =item CDATA
110 normal text (CDATA in the DTD)
112 =item TAG
114 something that has the form of an HTML tag
116 =item DECL
118 something that has the form of an SGML declaration
120 =item PI
122 something that has the form of an SGML processing instruction
124 =item DIRECTIVE
126 a Template Toolkit directive
128 =item COMMENT
130 something that has the form of an HTML comment
131 (and is not recognized as an HTML::Template directive)
133 =item UNKNOWN
135 something that is not recognized at all by the scanner
137 =back
139 Note that end of file is currently represented by undef,
140 instead of a constant predefined by this module.
142 =cut