HTML-Template-Pro-0.9524/ 0000755 0000764 0000764 00000000000 14171101161 013353 5 ustar igor igor HTML-Template-Pro-0.9524/pmiscdef.h 0000644 0000764 0000764 00000003167 11256720631 015337 0 ustar igor igor #ifndef _PMISCDEF_H
#define _PMISCDEF_H 1
#include
/* snprintf MS VC++ support;
* thanks to Viacheslav Sheveliov
*/
#ifdef _MSC_VER
# define snprintf _snprintf
#endif
/* printf ptrdiff_t format modifier */
#if __STDC_VERSION__ >= 199901L
# define TO_PTRDIFF_T(X) (X)
# define MOD_TD "%td"
#elif defined _MSC_VER
# define TO_PTRDIFF_T(X) (X)
# define MOD_TD "%Id"
#else
# define TO_PTRDIFF_T(X) ((long) (X))
# define MOD_TD "%ld"
#endif
#if ! defined HAVE_STRDUP && ! defined strdup
# if defined HAVE__STRDUP
# define strdup _strdup
# else
# define strdup(str) strcpy(malloc(strlen(str) + 1), str)
# endif
#endif
#define COMPILE_TIME_ASSERT(x) \
void __cta_proto__(int __cta_foo__[(x) ? 1 : -1])
#ifdef __GNUC__
#define FORMAT_PRINTF(X,Y) __attribute__ ((__format__ (__printf__, X, Y)))
#else
#define FORMAT_PRINTF(X,Y)
#endif
#if defined(__GNUC__) && !(defined(PEDANTIC))
#define INLINE inline
#else /* !__GNUC__ */
#define INLINE
#endif /* __GNUC__ */
/* C89 compatible flexible array
struct header {
size_t len;
unsigned char data[FLEXIBLE_SIZE];
};
struct header *my_header = malloc(SIZEOF_FLEXIBLE(struct header, data, n));
expands to
= malloc(offsetof(struct header, data) + n * sizeof my_header->data);
Setting FLEXIBLE_SIZE to SIZE_MAX almost ensures this will fail :
struct header *my_header = malloc(sizeof *my_header);
*/
#define FLEXIBLE_SIZE SIZE_MAX /* or whatever maximum length for an array */
#define SIZEOF_FLEXIBLE(type, member, length) \
( offsetof(type, member) + (length) * sizeof ((type *)0)->member[0] )
#endif /* pmiscdef.h */
/*
* Local Variables:
* mode: c
* End:
*/
HTML-Template-Pro-0.9524/LGPL 0000644 0000764 0000764 00000063502 11231403301 014035 0 ustar igor igor GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
HTML-Template-Pro-0.9524/calc.h 0000644 0000764 0000764 00000001240 11411143253 014425 0 ustar igor igor #include
#include "exprtype.h"
struct expr_parser;
/* Function types */
typedef double (*func_t_dd) (double);
typedef double (*func_t_ddd) (double,double);
typedef struct exprval (*func_t_ee) (struct expr_parser* exprobj, struct exprval);
#define SYMREC(X) X, sizeof(X)-1
/* memory is allocated at compile time. it is also thread safe */
struct symrec_const
{
char *name; /* name of symbol */
int len; /* symbol length */
int type; /* type of symbol: either VAR or FNCT */
double var; /* value of a VAR */
void* fnctptr; /* value of a FNCT */
};
typedef struct symrec_const symrec_const;
/*
Local Variables:
mode: c
End:
*/
HTML-Template-Pro-0.9524/exprtype.h 0000644 0000764 0000764 00000002524 11247444721 015424 0 ustar igor igor /*! \file exprtype.h
\brief description of EXPR variable type.
EXPR variable type is passed to and from user-supplied functions.
\author Igor Vlasenko
\warning This header file should never be included directly.
Include instead.
*/
#ifndef _EXPRTYPE_H
#define _EXPRTYPE_H 1
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_INTTYPES_H
# include
#else
# if HAVE_STDINT_H
# include
# endif
#endif
#define EXPR_TYPE_INT 'i'
#define EXPR_TYPE_DBL 'd'
#define EXPR_TYPE_PSTR 'p'
/* NULL is for interface only, internally NULL pstring is used. */
#define EXPR_TYPE_NULL '\0'
/* UPSTR is for internal use only. it is never passed to user functions. */
#define EXPR_TYPE_UPSTR 'u'
#if defined INT64_MAX || defined int64_t
typedef int64_t EXPR_int64;
#elif defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == 8
typedef long long int EXPR_int64;
#elif defined INT64_NAME
typedef INT64_NAME EXPR_int64;
#else
typedef long int EXPR_int64;
#endif
#if defined PRId64
# define EXPR_PRId64 PRId64
#elif defined SIZEOF_LONG_LONG && SIZEOF_LONG_LONG == 8
# define EXPR_PRId64 "lld"
#elif defined _MSC_VER
# define EXPR_PRId64 "I64d"
#else
# define EXPR_PRId64 "ld"
#endif
struct exprval;
#endif /* exprtype.h */
/*
* Local Variables:
* mode: c
* End:
*/
HTML-Template-Pro-0.9524/proparam.h 0000644 0000764 0000764 00000063621 11337040211 015354 0 ustar igor igor
/*! \file proparam.h
\brief Getters and setters for libhtmltmplpro options.
Public interface to get and set libhtmltmplpro options.
\author Igor Vlasenko
\warning This header file should never be included directly.
Include instead.
*/
/* generated; do not edit */
#ifndef _PROPARAM_H
#define _PROPARAM_H 1
struct tmplpro_param;
/*! \fn int tmplpro_get_option_global_vars(struct tmplpro_param*);
\brief get value of global_vars option.
see HTML::Template::Pro perl module documentation for global_vars option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_global_vars(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_global_vars(struct tmplpro_param*,int);
\brief set value of global_vars option.
see HTML::Template::Pro perl module documentation for global_vars option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_global_vars(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_max_includes(struct tmplpro_param*);
\brief get value of max_includes option.
see HTML::Template::Pro perl module documentation for max_includes option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_max_includes(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_max_includes(struct tmplpro_param*,int);
\brief set value of max_includes option.
see HTML::Template::Pro perl module documentation for max_includes option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_max_includes(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_debug(struct tmplpro_param*);
\brief get value of debug option.
see HTML::Template::Pro perl module documentation for debug option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_debug(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_debug(struct tmplpro_param*,int);
\brief set value of debug option.
see HTML::Template::Pro perl module documentation for debug option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_debug(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_tmpl_var_case(struct tmplpro_param*);
\brief get value of tmpl_var_case option.
see HTML::Template::Pro perl module documentation for tmpl_var_case option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_tmpl_var_case(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_tmpl_var_case(struct tmplpro_param*,int);
\brief set value of tmpl_var_case option.
see HTML::Template::Pro perl module documentation for tmpl_var_case option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_tmpl_var_case(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_no_includes(struct tmplpro_param*);
\brief get value of no_includes option.
see HTML::Template::Pro perl module documentation for no_includes option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_no_includes(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_no_includes(struct tmplpro_param*,int);
\brief set value of no_includes option.
see HTML::Template::Pro perl module documentation for no_includes option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_no_includes(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_loop_context_vars(struct tmplpro_param*);
\brief get value of loop_context_vars option.
see HTML::Template::Pro perl module documentation for loop_context_vars option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_loop_context_vars(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_loop_context_vars(struct tmplpro_param*,int);
\brief set value of loop_context_vars option.
see HTML::Template::Pro perl module documentation for loop_context_vars option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_loop_context_vars(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_strict(struct tmplpro_param*);
\brief get value of strict option.
see HTML::Template::Pro perl module documentation for strict option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_strict(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_strict(struct tmplpro_param*,int);
\brief set value of strict option.
see HTML::Template::Pro perl module documentation for strict option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_strict(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_filters(struct tmplpro_param*);
\brief get value of filters option.
see HTML::Template::Pro perl module documentation for filters option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_filters(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_filters(struct tmplpro_param*,int);
\brief set value of filters option.
see HTML::Template::Pro perl module documentation for filters option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_filters(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_default_escape(struct tmplpro_param*);
\brief get value of default_escape option.
see HTML::Template::Pro perl module documentation for default_escape option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_default_escape(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_default_escape(struct tmplpro_param*,int);
\brief set value of default_escape option.
see HTML::Template::Pro perl module documentation for default_escape option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_default_escape(struct tmplpro_param*,int);
/*! \fn const char* tmplpro_get_option_filename(struct tmplpro_param*);
\brief get value of filename option.
see HTML::Template::Pro perl module documentation for filename option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API const char* APICALL tmplpro_get_option_filename(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_filename(struct tmplpro_param*,const char*);
\brief set value of filename option.
see HTML::Template::Pro perl module documentation for filename option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_filename(struct tmplpro_param*,const char*);
/*! \fn PSTRING tmplpro_get_option_scalarref(struct tmplpro_param*);
\brief get value of scalarref option.
see HTML::Template::Pro perl module documentation for scalarref option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API PSTRING APICALL tmplpro_get_option_scalarref(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_scalarref(struct tmplpro_param*,PSTRING);
\brief set value of scalarref option.
see HTML::Template::Pro perl module documentation for scalarref option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_scalarref(struct tmplpro_param*,PSTRING);
/*! \fn int tmplpro_get_option_path_like_variable_scope(struct tmplpro_param*);
\brief get value of path_like_variable_scope option.
see HTML::Template::Pro perl module documentation for path_like_variable_scope option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_path_like_variable_scope(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_path_like_variable_scope(struct tmplpro_param*,int);
\brief set value of path_like_variable_scope option.
see HTML::Template::Pro perl module documentation for path_like_variable_scope option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_path_like_variable_scope(struct tmplpro_param*,int);
/*! \fn int tmplpro_get_option_search_path_on_include(struct tmplpro_param*);
\brief get value of search_path_on_include option.
see HTML::Template::Pro perl module documentation for search_path_on_include option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API int APICALL tmplpro_get_option_search_path_on_include(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_search_path_on_include(struct tmplpro_param*,int);
\brief set value of search_path_on_include option.
see HTML::Template::Pro perl module documentation for search_path_on_include option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_search_path_on_include(struct tmplpro_param*,int);
/*! \fn char** tmplpro_get_option_path(struct tmplpro_param*);
\brief get value of path option.
see HTML::Template::Pro perl module documentation for path option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API char** APICALL tmplpro_get_option_path(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_path(struct tmplpro_param*,char**);
\brief set value of path option.
see HTML::Template::Pro perl module documentation for path option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_path(struct tmplpro_param*,char**);
/*! \fn char* tmplpro_get_option_template_root(struct tmplpro_param*);
\brief get value of template_root option.
see HTML::Template::Pro perl module documentation for template_root option.
\param param -- pointer to an internal state.
*/
TMPLPRO_API char* APICALL tmplpro_get_option_template_root(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_template_root(struct tmplpro_param*,char*);
\brief set value of template_root option.
see HTML::Template::Pro perl module documentation for template_root option.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_template_root(struct tmplpro_param*,char*);
/*! \fn writer_functype tmplpro_get_option_WriterFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::writer_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API writer_functype APICALL tmplpro_get_option_WriterFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_WriterFuncPtr(struct tmplpro_param*,writer_functype);
\brief set callback of ::writer_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_WriterFuncPtr(struct tmplpro_param*,writer_functype);
/*! \fn get_ABSTRACT_VALUE_functype tmplpro_get_option_GetAbstractValFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::get_ABSTRACT_VALUE_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API get_ABSTRACT_VALUE_functype APICALL tmplpro_get_option_GetAbstractValFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_GetAbstractValFuncPtr(struct tmplpro_param*,get_ABSTRACT_VALUE_functype);
\brief set callback of ::get_ABSTRACT_VALUE_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_GetAbstractValFuncPtr(struct tmplpro_param*,get_ABSTRACT_VALUE_functype);
/*! \fn ABSTRACT_VALUE2PSTRING_functype tmplpro_get_option_AbstractVal2pstringFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::ABSTRACT_VALUE2PSTRING_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_VALUE2PSTRING_functype APICALL tmplpro_get_option_AbstractVal2pstringFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_AbstractVal2pstringFuncPtr(struct tmplpro_param*,ABSTRACT_VALUE2PSTRING_functype);
\brief set callback of ::ABSTRACT_VALUE2PSTRING_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_AbstractVal2pstringFuncPtr(struct tmplpro_param*,ABSTRACT_VALUE2PSTRING_functype);
/*! \fn ABSTRACT_VALUE2ABSTRACT_ARRAY_functype tmplpro_get_option_AbstractVal2abstractArrayFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_VALUE2ABSTRACT_ARRAY_functype APICALL tmplpro_get_option_AbstractVal2abstractArrayFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_AbstractVal2abstractArrayFuncPtr(struct tmplpro_param*,ABSTRACT_VALUE2ABSTRACT_ARRAY_functype);
\brief set callback of ::ABSTRACT_VALUE2ABSTRACT_ARRAY_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_AbstractVal2abstractArrayFuncPtr(struct tmplpro_param*,ABSTRACT_VALUE2ABSTRACT_ARRAY_functype);
/*! \fn get_ABSTRACT_ARRAY_length_functype tmplpro_get_option_GetAbstractArrayLengthFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::get_ABSTRACT_ARRAY_length_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API get_ABSTRACT_ARRAY_length_functype APICALL tmplpro_get_option_GetAbstractArrayLengthFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_GetAbstractArrayLengthFuncPtr(struct tmplpro_param*,get_ABSTRACT_ARRAY_length_functype);
\brief set callback of ::get_ABSTRACT_ARRAY_length_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_GetAbstractArrayLengthFuncPtr(struct tmplpro_param*,get_ABSTRACT_ARRAY_length_functype);
/*! \fn get_ABSTRACT_MAP_functype tmplpro_get_option_GetAbstractMapFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::get_ABSTRACT_MAP_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API get_ABSTRACT_MAP_functype APICALL tmplpro_get_option_GetAbstractMapFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_GetAbstractMapFuncPtr(struct tmplpro_param*,get_ABSTRACT_MAP_functype);
\brief set callback of ::get_ABSTRACT_MAP_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_GetAbstractMapFuncPtr(struct tmplpro_param*,get_ABSTRACT_MAP_functype);
/*! \fn is_ABSTRACT_VALUE_true_functype tmplpro_get_option_IsAbstractValTrueFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::is_ABSTRACT_VALUE_true_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API is_ABSTRACT_VALUE_true_functype APICALL tmplpro_get_option_IsAbstractValTrueFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_IsAbstractValTrueFuncPtr(struct tmplpro_param*,is_ABSTRACT_VALUE_true_functype);
\brief set callback of ::is_ABSTRACT_VALUE_true_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_IsAbstractValTrueFuncPtr(struct tmplpro_param*,is_ABSTRACT_VALUE_true_functype);
/*! \fn find_file_functype tmplpro_get_option_FindFileFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::find_file_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API find_file_functype APICALL tmplpro_get_option_FindFileFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_FindFileFuncPtr(struct tmplpro_param*,find_file_functype);
\brief set callback of ::find_file_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_FindFileFuncPtr(struct tmplpro_param*,find_file_functype);
/*! \fn load_file_functype tmplpro_get_option_LoadFileFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::load_file_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API load_file_functype APICALL tmplpro_get_option_LoadFileFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_LoadFileFuncPtr(struct tmplpro_param*,load_file_functype);
\brief set callback of ::load_file_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_LoadFileFuncPtr(struct tmplpro_param*,load_file_functype);
/*! \fn unload_file_functype tmplpro_get_option_UnloadFileFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::unload_file_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API unload_file_functype APICALL tmplpro_get_option_UnloadFileFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_UnloadFileFuncPtr(struct tmplpro_param*,unload_file_functype);
\brief set callback of ::unload_file_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_UnloadFileFuncPtr(struct tmplpro_param*,unload_file_functype);
/*! \fn exit_loop_scope_functype tmplpro_get_option_ExitLoopScopeFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::exit_loop_scope_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API exit_loop_scope_functype APICALL tmplpro_get_option_ExitLoopScopeFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ExitLoopScopeFuncPtr(struct tmplpro_param*,exit_loop_scope_functype);
\brief set callback of ::exit_loop_scope_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ExitLoopScopeFuncPtr(struct tmplpro_param*,exit_loop_scope_functype);
/*! \fn ABSTRACT_WRITER* tmplpro_get_option_ext_writer_state(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_WRITER.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_WRITER* APICALL tmplpro_get_option_ext_writer_state(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ext_writer_state(struct tmplpro_param*,ABSTRACT_WRITER*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_WRITER.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ext_writer_state(struct tmplpro_param*,ABSTRACT_WRITER*);
/*! \fn ABSTRACT_FILTER* tmplpro_get_option_ext_filter_state(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_FILTER.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_FILTER* APICALL tmplpro_get_option_ext_filter_state(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ext_filter_state(struct tmplpro_param*,ABSTRACT_FILTER*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_FILTER.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ext_filter_state(struct tmplpro_param*,ABSTRACT_FILTER*);
/*! \fn ABSTRACT_FINDFILE* tmplpro_get_option_ext_findfile_state(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_FINDFILE.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_FINDFILE* APICALL tmplpro_get_option_ext_findfile_state(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ext_findfile_state(struct tmplpro_param*,ABSTRACT_FINDFILE*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_FINDFILE.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ext_findfile_state(struct tmplpro_param*,ABSTRACT_FINDFILE*);
/*! \fn ABSTRACT_DATASTATE* tmplpro_get_option_ext_data_state(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_DATASTATE.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_DATASTATE* APICALL tmplpro_get_option_ext_data_state(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ext_data_state(struct tmplpro_param*,ABSTRACT_DATASTATE*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_DATASTATE.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ext_data_state(struct tmplpro_param*,ABSTRACT_DATASTATE*);
/*! \fn ABSTRACT_CALLER* tmplpro_get_option_ext_calluserfunc_state(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_CALLER.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_CALLER* APICALL tmplpro_get_option_ext_calluserfunc_state(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_ext_calluserfunc_state(struct tmplpro_param*,ABSTRACT_CALLER*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_CALLER.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_ext_calluserfunc_state(struct tmplpro_param*,ABSTRACT_CALLER*);
/*! \fn init_expr_arglist_functype tmplpro_get_option_InitExprArglistFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::init_expr_arglist_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API init_expr_arglist_functype APICALL tmplpro_get_option_InitExprArglistFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_InitExprArglistFuncPtr(struct tmplpro_param*,init_expr_arglist_functype);
\brief set callback of ::init_expr_arglist_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_InitExprArglistFuncPtr(struct tmplpro_param*,init_expr_arglist_functype);
/*! \fn free_expr_arglist_functype tmplpro_get_option_FreeExprArglistFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::free_expr_arglist_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API free_expr_arglist_functype APICALL tmplpro_get_option_FreeExprArglistFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_FreeExprArglistFuncPtr(struct tmplpro_param*,free_expr_arglist_functype);
\brief set callback of ::free_expr_arglist_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_FreeExprArglistFuncPtr(struct tmplpro_param*,free_expr_arglist_functype);
/*! \fn push_expr_arglist_functype tmplpro_get_option_PushExprArglistFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::push_expr_arglist_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API push_expr_arglist_functype APICALL tmplpro_get_option_PushExprArglistFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_PushExprArglistFuncPtr(struct tmplpro_param*,push_expr_arglist_functype);
\brief set callback of ::push_expr_arglist_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_PushExprArglistFuncPtr(struct tmplpro_param*,push_expr_arglist_functype);
/*! \fn call_expr_userfnc_functype tmplpro_get_option_CallExprUserfncFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::call_expr_userfnc_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API call_expr_userfnc_functype APICALL tmplpro_get_option_CallExprUserfncFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_CallExprUserfncFuncPtr(struct tmplpro_param*,call_expr_userfnc_functype);
\brief set callback of ::call_expr_userfnc_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_CallExprUserfncFuncPtr(struct tmplpro_param*,call_expr_userfnc_functype);
/*! \fn is_expr_userfnc_functype tmplpro_get_option_IsExprUserfncFuncPtr(struct tmplpro_param*);
\brief get address of callback of ::is_expr_userfnc_functype
\param param -- pointer to an internal state.
*/
TMPLPRO_API is_expr_userfnc_functype APICALL tmplpro_get_option_IsExprUserfncFuncPtr(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_IsExprUserfncFuncPtr(struct tmplpro_param*,is_expr_userfnc_functype);
\brief set callback of ::is_expr_userfnc_functype
\param param -- pointer to an internal state.
\param val -- callback address to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_IsExprUserfncFuncPtr(struct tmplpro_param*,is_expr_userfnc_functype);
/*! \fn ABSTRACT_FUNCMAP* tmplpro_get_option_expr_func_map(struct tmplpro_param*);
\brief get value of an external pointer that will be passed to a callback. see ::ABSTRACT_FUNCMAP.
\param param -- pointer to an internal state.
*/
TMPLPRO_API ABSTRACT_FUNCMAP* APICALL tmplpro_get_option_expr_func_map(struct tmplpro_param*);
/*! \fn void tmplpro_set_option_expr_func_map(struct tmplpro_param*,ABSTRACT_FUNCMAP*);
\brief set external pointer that will be passed to a callback. see ::ABSTRACT_FUNCMAP.
\param param -- pointer to an internal state.
\param val -- value to set.
*/
TMPLPRO_API void APICALL tmplpro_set_option_expr_func_map(struct tmplpro_param*,ABSTRACT_FUNCMAP*);
#endif /* proparam.h */
HTML-Template-Pro-0.9524/lib/ 0000755 0000764 0000764 00000000000 14171101161 014121 5 ustar igor igor HTML-Template-Pro-0.9524/lib/HTML/ 0000755 0000764 0000764 00000000000 14171101161 014665 5 ustar igor igor HTML-Template-Pro-0.9524/lib/HTML/Template/ 0000755 0000764 0000764 00000000000 14171101161 016440 5 ustar igor igor HTML-Template-Pro-0.9524/lib/HTML/Template/PerlInterface.pod 0000644 0000764 0000764 00000103712 12144121772 021703 0 ustar igor igor =head1 NAME
HTML::Template::PerlInterface - perl interface of HTML::Template::Pro
=head1 SYNOPSIS
This help is only on perl interface of HTML::Template::Pro.
For syntax of html template files you should see
L.
First you make a template - this is just a normal HTML file with a few
extra tags, the simplest being
For example, test.tmpl:
Test Template
My Home Directory is
My Path is set to
See L for their syntax.
Now create a small CGI program:
#!/usr/bin/perl -w
use HTML::Template::Pro;
# open the html template
my $template = HTML::Template::Pro->new(
filename => 'test.tmpl',
case_sensitive=> 1);
# fill in some parameters
$template->param(HOME => $ENV{HOME});
$template->param(PATH => $ENV{PATH});
# send the obligatory Content-Type and print the template output
print "Content-Type: text/html\n\n";
# print output
$template->output(print_to=>\*STDOUT);
# this would also work.
# print $template->output();
# this would also work. It is faster,
# but (WARNING!) not compatible with original HTML::Template.
# $template->output();
If all is well in the universe this should show something like this in
your browser when visiting the CGI:
My Home Directory is /home/some/directory
My Path is set to /bin;/usr/bin
For the best performance it is recommended to use
case_sensitive=>1 in new()
and print_to=>\*STDOUT in output().
Note that (HTML::Template::Pro version 0.90+)
output(), called in void context, also prints to stdout
using built-in htmltmplpro C library calls, so the last call
"$template->output();"
might be, in fact, the fastest way to call output().
IMPORTANT NOTE: you can safely write
my $template = HTML::Template->new( ... options ...)
or even
my $template = HTML::Template::Expr->new( ... options ...)
with HTML::Template::Pro, because in absence of original HTML::Template
and HTML::Template::Expr HTML::Template::Pro intercepts their calls.
You can also use all three modules and safely mix their calls
(benchmarking may be the only reason for it).
In case you want to mix calls to HTML::Template::Expr and
HTML::Template::Pro, the only proper usage of their load is
use HTML::Template;
use HTML::Template::Expr;
use HTML::Template::Pro;
Of course, if you don't plan to mix them (in most cases)
it is enough to simply write
use HTML::Template::Pro;
Simply use HTML::Template::Pro,
it supports all functions of HTML::Template::Expr.
=head1 DESCRIPTION
HTML::Template::Pro is a fast C/perl+XS implementation of HTML::Template
and HTML::Template::Expr.
See L for details.
It fully supports template language of HTML::Template
as described in L.
Briefly,
"This module attempts to make using HTML templates simple and natural.
It extends standard HTML with a few new HTML-esque tags - ,
, , , and .
The file written with HTML and these new tags is called a template.
It is usually saved separate from your script - possibly even created
by someone else! Using this module you fill in the values for the
variables, loops and branches declared in the template. This allows
you to separate design - the HTML - from the data, which you generate
in the Perl script."
Here is described a perl interface of HTML::Template::Pro and
HTML::Template + HTML::Template::Expr.
See B for brief summary of distinctions between
HTML::Template::Pro and HTML::Template.
=head1 METHODS
=head2 new()
Call new() to create a new Template object:
my $template = HTML::Template->new( filename => 'file.tmpl',
option => 'value'
);
You must call new() with at least one name => value pair specifying how
to access the template text. You can use C<< filename => 'file.tmpl' >>
to specify a filename to be opened as the template. Alternately you can
use:
my $t = HTML::Template->new( scalarref => $ref_to_template_text,
option => 'value'
);
and
my $t = HTML::Template->new( arrayref => $ref_to_array_of_lines ,
option => 'value'
);
These initialize the template from in-memory resources. In almost
every case you'll want to use the filename parameter. If you're
worried about all the disk access from reading a template file just
use mod_perl and the cache option detailed below.
You can also read the template from an already opened filehandle,
either traditionally as a glob or as a FileHandle:
my $t = HTML::Template->new( filehandle => *FH, option => 'value');
The four new() calling methods can also be accessed as below, if you
prefer.
my $t = HTML::Template->new_file('file.tmpl', option => 'value');
my $t = HTML::Template->new_scalar_ref($ref_to_template_text,
option => 'value');
my $t = HTML::Template->new_array_ref($ref_to_array_of_lines,
option => 'value');
my $t = HTML::Template->new_filehandle($fh,
option => 'value');
And as a final option, for those that might prefer it, you can call new as:
my $t = HTML::Template->new(type => 'filename',
source => 'file.tmpl');
Which works for all three of the source types.
If the environment variable HTML_TEMPLATE_ROOT is set and your
filename doesn't begin with /, then the path will be relative to the
value of $HTML_TEMPLATE_ROOT. Example - if the environment variable
HTML_TEMPLATE_ROOT is set to "/home/sam" and I call
HTML::Template->new() with filename set to "sam.tmpl", the
HTML::Template will try to open "/home/sam/sam.tmpl" to access the
template file. You can also affect the search path for files with the
"path" option to new() - see below for more information.
You can modify the Template object's behavior with new(). The options
are available:
=over 4
=item Error Detection Options
=over 4
=item *
die_on_bad_params - if set to 0 the module will let you call
$template->param(param_name => 'value') even if 'param_name' doesn't
exist in the template body. Defaults to 1 in HTML::Template.
HTML::Template::Pro always use die_on_bad_params => 0.
It currently can't be changed, because HTML::Template::Pro can't
know whether a parameter is bad until it finishes output.
Note that it is wrapper-only option: it is not implemented
in the htmltmplpro C library.
=item *
force_untaint - if set to 1 the module will not allow you to set
unescaped parameters with tainted values. If set to 2 you will have
to untaint all parameters, including ones with the escape attribute.
This option makes sure you untaint everything so you don't accidentally
introduce e.g. cross-site-scripting (CSS) vulnerabilities. Requires
taint mode. Defaults to 0.
In the original HTML::Template, if the "force_untaint" option is set
an error occurs if you try to set a value that is tainted in the param()
call. In HTML::Template::Pro, an error occurs when output is called.
Note that the tainted value will never be printed; but, to completely
suppress output, one should use call to output() that returns string,
like
print $tmpl->output();
Then output() will die before it returns the string to print.
Note that it is wrapper-only perl-specific option: it is not
implemented in the htmltmplpro C library.
=item *
strict - if set to 0 the module will allow things that look like they
might be TMPL_* tags to get by without dieing. Example:
Would normally cause an error, but if you call new with strict => 0,
HTML::Template will ignore it. Defaults to 1.
HTML::Template::Pro always implies strict => 0.
=begin comment
=item *
vanguard_compatibility_mode - if set to 1 the module will expect to
see s that look like %NAME% in addition to the standard
syntax. Also sets die_on_bad_params => 0. If you're not at Vanguard
Media trying to use an old format template don't worry about this one.
Defaults to 0.
vanguard_compatibility_mode is not supported in HTML::Template::Pro.
=end comment
=back
=item Caching Options
HTML::Template use many caching options such as
cache, shared_cache, double_cache, blind_cache, file_cache,
file_cache_dir, file_cache_dir_mode, double_file_cache
to cache preparsed html templates.
Since HTML::Template::Pro parses and outputs templates at once,
it silently ignores those options.
=item Filesystem Options
=over 4
=item *
path - you can set this variable with a list of paths to search for
files specified with the "filename" option to new() and for files
included with the tag. This list is only consulted
when the filename is relative. The HTML_TEMPLATE_ROOT environment
variable is always tried first if it exists. Also, if
HTML_TEMPLATE_ROOT is set then an attempt will be made to prepend
HTML_TEMPLATE_ROOT onto paths in the path array. In the case of a
file, the path to the including file is also tried
before path is consulted.
Example:
my $template = HTML::Template->new( filename => 'file.tmpl',
path => [ '/path/to/templates',
'/alternate/path'
]
);
NOTE: the paths in the path list must be expressed as UNIX paths,
separated by the forward-slash character ('/').
=item *
search_path_on_include - if set to a true value the module will search
from the top of the array of paths specified by the path option on
every and use the first matching template found. The
normal behavior is to look only in the current directory for a
template to include. Defaults to 0.
=back
=item Debugging Options
=over 4
=item *
debug - if set to 1 the module will write random debugging information
to STDERR. Defaults to 0.
=item *
HTML::Template use many cache debug options such as
stack_debug, cache_debug, shared_cache_debug, memory_debug.
Since HTML::Template::Pro parses and outputs templates at once,
it silently ignores those options.
=back
=item Miscellaneous Options
=over 4
=item *
associate - this option allows you to inherit the parameter values
from other objects. The only requirement for the other object is that
it have a C method that works like HTML::Template's C. A
good candidate would be a CGI.pm query object. Example:
my $query = new CGI;
my $template = HTML::Template->new(filename => 'template.tmpl',
associate => $query);
Now, C<< $template->output() >> will act as though
$template->param('FormField', $cgi->param('FormField'));
had been specified for each key/value pair that would be provided by
the C<< $cgi->param() >> method. Parameters you set directly take
precedence over associated parameters.
You can specify multiple objects to associate by passing an anonymous
array to the associate option. They are searched for parameters in
the order they appear:
my $template = HTML::Template->new(filename => 'template.tmpl',
associate => [$query, $other_obj]);
=begin comment
The old associateCGI() call is still supported, but should be
considered obsolete.
=end comment
NOTE: If the option case_sensitive => 0,
the parameter names are matched in a case-insensitive manner. If
you have two parameters in a CGI object like 'NAME' and 'Name' one
will be chosen randomly by associate. This behavior can be changed by
setting option case_sensitive to 1.
=item *
case_sensitive - setting this option to true causes HTML::Template to
treat template variable names case-sensitively. The following example
would only set one parameter without the "case_sensitive" option:
my $template = HTML::Template->new(filename => 'template.tmpl',
case_sensitive => 1);
$template->param(
FieldA => 'foo',
fIELDa => 'bar',
);
This option defaults to off to keep compatibility with HTML::Template.
Nevertheless, setting case_sensitive => 1 is encouraged, because
it significantly improves performance.
If case_sensitive is set to 0, the perl wrapper is forced to lowercase
keys in every hash it will find in "param" tree, which is sometimes
an expensive operation. To avoid this, set case_sensitive => 1.
If case conversion is necessary, there is an alternative lightweight
option tmpl_var_case, which is HTML::Template::Pro specific.
Note that case_sensitive is wrapper-only option: it is not implemented
in the htmltmplpro C library.
=item *
tmpl_var_case - this option is similar to case_sensitive, but is
implemented directly in the htmltmplpro C library.
Instead of converting keys in every hash of "param" tree, it
converts the name of variable.
For example, in case of setting
tmpl_var_case = ASK_NAME_AS_IS | ASK_NAME_LOWERCASE | ASK_NAME_UPPERCASE
will cause HTML::Template::Pro to look into "param" tree for 3 names:
CamelCaseName, camelcasename, and CAMELCASENAME.
By default, the name is asked "as is".
=item *
loop_context_vars - when this parameter is set to true (it is false by
default) four loop context variables are made available inside a loop:
__first__, __last__, __inner__, __odd__. They can be used with
, and to control how a loop is
output.
In addition to the above, a __counter__ var is also made available
when loop context variables are turned on.
Example:
This only outputs on the first pass.
This outputs every other pass, on the odd passes.
This outputs every other pass, on the even passes.
This outputs on passes that are neither first nor last.
This is pass number .
This only outputs on the last pass.
One use of this feature is to provide a "separator" similar in effect
to the perl function join(). Example:
and , .
Would output (in a browser) something like:
Apples, Oranges, Brains, Toes, and Kiwi.
Given an appropriate C call, of course. NOTE: A loop with only
a single pass will get both __first__ and __last__ set to true, but
not __inner__.
NOTE: in the original HTML::Template with case_sensitive = 1 and loop_context_vars
the special loop variables are available in lower-case only.
In HTML::Template::Pro they are recognized regardless of case.
=item *
no_includes - set this option to 1 to disallow the tag
in the template file. This can be used to make opening untrusted
templates B less dangerous. Defaults to 0.
=item *
max_includes - set this variable to determine the maximum depth that
includes can reach. Set to 10 by default. Including files to a depth
greater than this value causes an error message to be displayed. Set
to 0 to disable this protection.
=item *
global_vars - normally variables declared outside a loop are not
available inside a loop. This option makes s like global
variables in Perl - they have unlimited scope. This option also
affects and .
Example:
This is a normal variable: .
Here it is inside the loop:
Normally this wouldn't work as expected, since 's
value outside the loop is not available inside the loop.
The global_vars option also allows you to access the values of an
enclosing loop within an inner loop. For example, in this loop the
inner loop will have access to the value of OUTER_VAR in the correct
iteration:
OUTER:
INNER:
INSIDE OUT:
B: C is not C (which does not exist).
That means that loops you declare at one scope are not available
inside other loops even when C is on.
=item *
path_like_variable_scope - this option switches on a Shigeki Morimoto
extension to HTML::Template::Pro that allows access to variables that
are outside the current loop scope using path-like expressions.
Example:
{{{
}}}
=item *
filter - this option allows you to specify a filter for your template
files. A filter is a subroutine that will be called after
HTML::Template reads your template file but before it starts parsing
template tags.
In the most simple usage, you simply assign a code reference to the
filter parameter. This subroutine will receive a single argument - a
reference to a string containing the template file text. Here is an
example that accepts templates with tags that look like "!!!ZAP_VAR
FOO!!!" and transforms them into HTML::Template tags:
my $filter = sub {
my $text_ref = shift;
$$text_ref =~ s/!!!ZAP_(.*?)!!!//g;
};
# open zap.tmpl using the above filter
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => $filter);
More complicated usages are possible. You can request that your
filter receive the template text as an array of lines rather than as
a single scalar. To do that you need to specify your filter using a
hash-ref. In this form you specify the filter using the C key and
the desired argument format using the C key. The available
formats are C and C. Using the C format will incur
a performance penalty but may be more convenient in some situations.
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => { sub => $filter,
format => 'array' });
You may also have multiple filters. This allows simple filters to be
combined for more elaborate functionality. To do this you specify an
array of filters. The filters are applied in the order they are
specified.
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => [
{ sub => \&decompress,
format => 'scalar' },
{ sub => \&remove_spaces,
format => 'array' }
]);
The specified filters will be called for any TMPL_INCLUDEed files just
as they are for the main template file.
=item *
default_escape - Set this parameter to "HTML", "URL" or "JS" and
HTML::Template will apply the specified escaping to all variables
unless they declare a different escape in the template.
=back
=back
=cut
=head2 param()
C can be called in a number of ways
1) To return a list of parameters in the template :
( this features is distinct in HTML::Template::Pro:
it returns a list of parameters _SET_ after new() )
my @parameter_names = $self->param();
2) To return the value set to a param :
my $value = $self->param('PARAM');
3) To set the value of a parameter :
# For simple TMPL_VARs:
$self->param(PARAM => 'value');
# with a subroutine reference that gets called to get the value
# of the scalar. The sub will receive the template object as a
# parameter.
$self->param(PARAM => sub { return 'value' });
# And TMPL_LOOPs:
$self->param(LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
);
4) To set the value of a a number of parameters :
# For simple TMPL_VARs:
$self->param(PARAM => 'value',
PARAM2 => 'value'
);
# And with some TMPL_LOOPs:
$self->param(PARAM => 'value',
PARAM2 => 'value',
LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
],
ANOTHER_LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
);
5) To set the value of a a number of parameters using a hash-ref :
$self->param(
{
PARAM => 'value',
PARAM2 => 'value',
LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
],
ANOTHER_LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
}
);
=cut
=pod
=head2 clear_params()
Sets all the parameters to undef. Useful internally, if nowhere else!
=head2 output()
output() returns the final result of the template. In most situations
you'll want to print this, like:
print $template->output();
When output is called each occurrence of is
replaced with the value assigned to "name" via C. If a named
parameter is unset it is simply replaced with ''. are
evaluated once per parameter set, accumulating output on each pass.
Calling output() is guaranteed not to change the state of the
Template object, in case you were wondering. This property is mostly
important for the internal implementation of loops.
You may optionally supply a filehandle to print to automatically as
the template is generated. This may improve performance and lower
memory consumption. Example:
$template->output(print_to => *STDOUT);
The return value is undefined when using the C option.
=head2 query()
This method is not supported in HTML::Template::Pro.
=begin comment
This method allow you to get information about the template structure.
It can be called in a number of ways. The simplest usage of query is
simply to check whether a parameter name exists in the template, using
the C option:
if ($template->query(name => 'foo')) {
# do something if a varaible of any type
# named FOO is in the template
}
This same usage returns the type of the parameter. The type is the
same as the tag minus the leading 'TMPL_'. So, for example, a
TMPL_VAR parameter returns 'VAR' from C.
if ($template->query(name => 'foo') eq 'VAR') {
# do something if FOO exists and is a TMPL_VAR
}
Note that the variables associated with TMPL_IFs and TMPL_UNLESSs will
be identified as 'VAR' unless they are also used in a TMPL_LOOP, in
which case they will return 'LOOP'.
C also allows you to get a list of parameters inside a loop
(and inside loops inside loops). Example loop:
And some query calls:
# returns 'LOOP'
$type = $template->query(name => 'EXAMPLE_LOOP');
# returns ('bop', 'bee', 'example_inner_loop')
@param_names = $template->query(loop => 'EXAMPLE_LOOP');
# both return 'VAR'
$type = $template->query(name => ['EXAMPLE_LOOP', 'BEE']);
$type = $template->query(name => ['EXAMPLE_LOOP', 'BOP']);
# and this one returns 'LOOP'
$type = $template->query(name => ['EXAMPLE_LOOP',
'EXAMPLE_INNER_LOOP']);
# and finally, this returns ('inner_bee', 'inner_bop')
@inner_param_names = $template->query(loop => ['EXAMPLE_LOOP',
'EXAMPLE_INNER_LOOP']);
# for non existent parameter names you get undef
# this returns undef.
$type = $template->query(name => 'DWEAZLE_ZAPPA');
# calling loop on a non-loop parameter name will cause an error.
# this dies:
$type = $template->query(loop => 'DWEAZLE_ZAPPA');
As you can see above the C option returns a list of parameter
names and both C and C take array refs in order to refer
to parameters inside loops. It is an error to use C with a
parameter that is not a loop.
Note that all the names are returned in lowercase and the types are
uppercase.
Just like C, C with no arguments returns all the
parameter names in the template at the top level.
=end comment
=cut
=head1 DISTINCTIONS AND INCOMPATIBILITIES
The main reason for small incompatibilities between HTML::Template and
HTML::Template::Pro is the fact that HTML::Template builds parsed tree of
template before anything else. So it has an additional information
which HTML::Template::Pro obtains during output.
In cases when HTML::Template dies, such as no_includes,
bad syntax of template, max_includes and so on,
HTML::Template::Pro issues warning to STDERR and continue.
=head2 new()
the following options are not supported in HTML::Template::Pro:
vanguard_compatibility_mode.
The options die_on_bad_params and strict are ignored.
HTML::Template::Pro behaves itself as HTML::Template called with
die_on_bad_params => 0, strict => 0.
It currently can't be changed, because HTML::Template::Pro can't
know whether a parameter is bad before it start output.
This may change in future releases.
To keep backward compatibility with HTML::Template, you should
explicitly call its new() with die_on_bad_params => 0, strict => 0.
=head2 query()
This method is not supported in HTML::Template::Pro.
=head2 param()
param() without arguments should return a list of parameters in the template.
In HTML::Template::Pro it returns a list of parameters set after new().
=head1 BUGS
With I and I the special loop
variables should be available in lower-case only.
I is case_sensitive inside loops.
=begin comment
I am aware of no bugs - if you find one, join the mailing list and
tell us about it. You can join the HTML::Template mailing-list by
visiting:
http://lists.sourceforge.net/lists/listinfo/html-template-users
Of course, you can still email me directly (sam@tregar.com) with bugs,
but I reserve the right to forward bug reports to the mailing list.
=end comment
When submitting bug reports, be sure to include full details,
including the VERSION of the module, a test script and a test template
demonstrating the problem!
=begin comment
If you're feeling really adventurous, HTML::Template has a publically
available Subversion server. See below for more information in the PUBLIC
SUBVERSION SERVER section.
=end comment
=head1 EXPR: DEFINING NEW FUNCTIONS
To define a new function, pass a C option to new:
$t = HTML::Template::Pro->new(filename => 'foo.tmpl',
functions =>
{ func_name => \&func_handler });
or
$t = HTML::Template::Expr->new(filename => 'foo.tmpl',
functions =>
{ func_name => \&func_handler });
Or, you can use C class method to register
the function globally:
HTML::Template::Pro->register_function(func_name => \&func_handler);
or
HTML::Template::Expr->register_function(func_name => \&func_handler);
You provide a subroutine reference that will be called during output.
It will receive as arguments the parameters specified in the template.
For example, here's a function that checks if a directory exists:
sub directory_exists {
my $dir_name = shift;
return 1 if -d $dir_name;
return 0;
}
If you call HTML::Template::Expr->new() with a C arg:
$t = HTML::Template::Expr->new(filename => 'foo.tmpl',
functions => {
directory_exists => \&directory_exists
});
Then you can use it in your template:
This can be abused in ways that make my teeth hurt.
=head2 register_function() extended usage (HTML::Template::Pro specific)
C can be called in a number of ways
1) To fetch the names of registered functions in the template:
=over 4
=item *
if C was called in a newly created object it returns a
list of function's that set _after_ or _in_ new():
my @registered_functions_names = $self->register_function();
=item *
in global context C will return a list of _ALL_
avalible function's
my @all_avalible_functions_names =
HTML::Template::Pro->register_function();
2) To fetching the function by name:
my $function = $self->register_function('FUNCTION_NAME');
3) To set a new function:
# Set function, that can be called in templates, wich are processed
# by the current object:
$self->register_function(foozicate => sub { ... });
# Set global function:
HTML::Template::Pro->register_function(barify => sub { ... });
=back
for details of "how to defined a function" see in
L.
=head1 EXPR MOD_PERL TIP
C class method can be called in mod_perl's
startup.pl to define widely used common functions to
HTML::Template::Expr. Add something like this to your startup.pl:
use HTML::Template::Pro;
HTML::Template::Pro->register_function(foozicate => sub { ... });
HTML::Template::Pro->register_function(barify => sub { ... });
HTML::Template::Pro->register_function(baznate => sub { ... });
=head1 EXPR CAVEATS
HTML::Template::Pro does not forces the HTML::Template global_vars
option to be set, whereas currently HTML::Template::Expr does.
Anyway, this also will hopefully go away in a future version of
HTML::Template::Expr, so if you need global_vars in your templates
then you should set it explicitly.
=head1 CREDITS
to Sam Tregar, sam@tregar.com
Original credits of HTML::Template:
This module was the brain child of my boss, Jesse Erlbaum
( jesse@vm.com ) at Vanguard Media ( http://vm.com ) . The most original
idea in this module - the - was entirely his.
Fixes, Bug Reports, Optimizations and Ideas have been generously
provided by:
Richard Chen
Mike Blazer
Adriano Nagelschmidt Rodrigues
Andrej Mikus
Ilya Obshadko
Kevin Puetz
Steve Reppucci
Richard Dice
Tom Hukins
Eric Zylberstejn
David Glasser
Peter Marelas
James William Carlson
Frank D. Cringle
Winfried Koenig
Matthew Wickline
Doug Steinwand
Drew Taylor
Tobias Brox
Michael Lloyd
Simran Gambhir
Chris Houser
Larry Moore
Todd Larason
Jody Biggs
T.J. Mather
Martin Schroth
Dave Wolfe
uchum
Kawai Takanori
Peter Guelich
Chris Nokleberg
Ralph Corderoy
William Ward
Ade Olonoh
Mark Stosberg
Lance Thomas
Roland Giersig
Jere Julian
Peter Leonard
Kenny Smith
Sean P. Scanlon
Martin Pfeffer
David Ferrance
Gyepi Sam
Darren Chamberlain
Paul Baker
Gabor Szabo
Craig Manley
Richard Fein
The Phalanx Project
Sven Neuhaus
Thanks!
Original credits of HTML::Template::Expr:
The following people have generously submitted bug reports, patches
and ideas:
Peter Leonard
Tatsuhiko Miyagawa
Thanks!
=head1 WEBSITE
You can find information about HTML::Template::Pro at:
http://html-tmpl-pro.sourceforge.net
You can find information about HTML::Template and other related modules at:
http://html-template.sourceforge.net
=begin comment
=head1 PUBLIC SUBVERSION SERVER
HTML::Template now has a publicly accessible Subversion server
provided by SourceForge (www.sourceforge.net). You can access it by
going to http://sourceforge.net/svn/?group_id=1075. Give it a try!
=end comment
=head1 AUTHOR
Sam Tregar, sam@tregar.com (Main text)
I. Vlasenko, Eviy@altlinux.orgE (Pecularities of HTML::Template::Pro)
=head1 LICENSE
HTML::Template : A module for using HTML Templates with Perl
Copyright (C) 2000-2002 Sam Tregar (sam@tregar.com)
This module is free software; you can redistribute it and/or modify it
under the terms of either:
a) the GNU General Public License as published by the Free Software
Foundation; either version 1, or (at your option) any later version,
or
b) the "Artistic License" which comes with this module.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
the GNU General Public License or the Artistic License for more details.
You should have received a copy of the Artistic License with this
module, in the file ARTISTIC. If not, I'll be glad to provide one.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
=cut
HTML-Template-Pro-0.9524/lib/HTML/Template/Pro.pm 0000644 0000764 0000764 00000041223 14171100705 017543 0 ustar igor igor package HTML::Template::Pro;
use 5.005;
use strict;
use integer; # no floating point math so far!
use HTML::Template::Pro::WrapAssociate;
use File::Spec; # generate paths that work on all platforms
use Scalar::Util qw(tainted);
use Carp;
require DynaLoader;
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(DynaLoader Exporter);
$VERSION = '0.9524';
@EXPORT_OK = qw/ASK_NAME_DEFAULT ASK_NAME_AS_IS ASK_NAME_LOWERCASE ASK_NAME_UPPERCASE ASK_NAME_MASK/;
%EXPORT_TAGS = (const => [qw/ASK_NAME_DEFAULT ASK_NAME_AS_IS ASK_NAME_LOWERCASE ASK_NAME_UPPERCASE ASK_NAME_MASK/]);
# constants for tmpl_var_case
use constant {
ASK_NAME_DEFAULT => 0,
ASK_NAME_AS_IS => 1,
ASK_NAME_LOWERCASE => 2,
ASK_NAME_UPPERCASE => 4,
};
use constant ASK_NAME_MASK => ASK_NAME_AS_IS | ASK_NAME_LOWERCASE | ASK_NAME_UPPERCASE;
bootstrap HTML::Template::Pro $VERSION;
## when HTML::Template is not loaded,
## all calls to HTML::Template will be sent to HTML::Template::Pro,
## otherwise native HTML::Template will be used
push @HTML::Template::ISA, qw/HTML::Template::Pro/;
push @HTML::Template::Expr::ISA, qw/HTML::Template::Pro/;
# Preloaded methods go here.
# internal C library init -- required
_init();
# internal C library unload -- it is better to comment it:
# when process terminates, memory is freed anyway
# but END {} can be called between calls (as SpeedyCGI does)
# END {_done()}
# initialize preset function table
use vars qw(%FUNC);
%FUNC =
(
# note that length,defined,sin,cos,log,tan,... are built-in
'sprintf' => sub { sprintf(shift, @_); },
'substr' => sub {
return substr($_[0], $_[1]) if @_ == 2;
return substr($_[0], $_[1], $_[2]);
},
'lc' => sub { lc($_[0]); },
'lcfirst' => sub { lcfirst($_[0]); },
'uc' => sub { uc($_[0]); },
'ucfirst' => sub { ucfirst($_[0]); },
# 'length' => sub { length($_[0]); },
# 'defined' => sub { defined($_[0]); },
# 'abs' => sub { abs($_[0]); },
# 'hex' => sub { hex($_[0]); },
# 'oct' => sub { oct($_[0]); },
'rand' => sub { rand($_[0]); },
'srand' => sub { srand($_[0]); },
);
sub new {
my $class=shift;
my %param;
my $options={param_map=>\%param,
functions => {},
filter => [],
# ---- supported -------
debug => 0,
max_includes => 10,
global_vars => 0,
no_includes => 0,
search_path_on_include => 0,
loop_context_vars => 0,
path => [],
associate => [],
case_sensitive => 0,
__strict_compatibility => 1,
force_untaint => 0,
# ---- unsupported distinct -------
die_on_bad_params => 0,
strict => 0,
# ---- unsupported -------
# vanguard_compatibility_mode => 0,
#=============================================
# The following options are harmless caching-specific.
# They are ignored silently because there is nothing to cache.
#=============================================
# stack_debug => 0,
# timing => 0,
# cache => 0,
# blind_cache => 0,
# file_cache => 0,
# file_cache_dir => '',
# file_cache_dir_mode => 0700,
# cache_debug => 0,
# shared_cache_debug => 0,
# memory_debug => 0,
# shared_cache => 0,
# double_cache => 0,
# double_file_cache => 0,
# ipc_key => 'TMPL',
# ipc_mode => 0666,
# ipc_segment_size => 65536,
# ipc_max_size => 0,
#============================================
@_};
# make sure taint mode is on if force_untaint flag is set
if ($options->{force_untaint} && ! ${^TAINT}) {
croak("HTML::Template->new() : 'force_untaint' option set but perl does not run in taint mode!");
}
# associate should be an array if it's not already
if (ref($options->{associate}) ne 'ARRAY') {
$options->{associate} = [ $options->{associate} ];
}
# path should be an array if it's not already
if (ref($options->{path}) ne 'ARRAY') {
$options->{path} = [ $options->{path} ];
}
# filter should be an array if it's not already
if (ref($options->{filter}) ne 'ARRAY') {
$options->{filter} = [ $options->{filter} ];
}
my $case_sensitive = $options->{case_sensitive};
my $__strict_compatibility = $options->{__strict_compatibility};
# wrap associated objects into tied hash and
# make sure objects in associate are support param()
$options->{associate} = [
map {HTML::Template::Pro::WrapAssociate->_wrap($_, $case_sensitive, $__strict_compatibility)}
@{$options->{associate}}
];
# check for syntax errors:
my $source_count = 0;
exists($options->{filename}) and $source_count++;
exists($options->{filehandle}) and $source_count++;
exists($options->{arrayref}) and $source_count++;
exists($options->{scalarref}) and $source_count++;
if ($source_count != 1) {
croak("HTML::Template->new called with multiple (or no) template sources specified! A valid call to new() has exactly one filename => 'file' OR exactly one scalarref => \\\$scalar OR exactly one arrayref => \\\@array OR exactly one filehandle => \*FH");
}
if ($options->{arrayref}) {
die "bad value of arrayref" unless UNIVERSAL::isa($_[0], 'ARRAY');
my $template=join('',@{$options->{arrayref}});
$options->{scalarref}=\$template;
}
if ($options->{filehandle}) {
local $/; # enable "slurp" mode
local *FH=$options->{filehandle};
my $template=;
$options->{scalarref}=\$template;
}
# merging built_in funcs with user-defined funcs
$options->{expr_func}={%FUNC, %{$options->{functions}}};
# hack to be fully compatible with HTML::Template;
# caused serious memory leak. it should be done on XS level, if needed.
# &safe_circular_reference($options,'options') ???
#$options->{options}=$options;
bless $options,$class;
$options->_call_filters($options->{scalarref}) if $options->{scalarref} and @{$options->{filter}};
return $options; # == $self
}
# a few shortcuts to new(), of possible use...
sub new_file {
my $pkg = shift; return $pkg->new('filename', @_);
}
sub new_filehandle {
my $pkg = shift; return $pkg->new('filehandle', @_);
}
sub new_array_ref {
my $pkg = shift; return $pkg->new('arrayref', @_);
}
sub new_scalar_ref {
my $pkg = shift; return $pkg->new('scalarref', @_);
}
sub output {
my $self=shift;
my %oparam=(@_);
my $print_to = $oparam{print_to};
if (defined wantarray && ! $print_to) {
return exec_tmpl_string($self);
} else {
exec_tmpl($self,$print_to);
}
}
sub clear_params {
my $self = shift;
%{$self->{param_map}}=();
}
sub param {
my $self = shift;
#my $options = $self->{options};
my $param_map = $self->{param_map};
# compatibility with HTML::Template
# the one-parameter case - could be a parameter value request or a
# hash-ref.
if (scalar @_==0) {
return keys (%$param_map);
} elsif (scalar @_==1) {
if (ref($_[0]) and UNIVERSAL::isa($_[0], 'HASH')) {
# ref to hash of params --- simply dereference it
return $self->param(%{$_[0]});
} else {
my $key=$self->{case_sensitive} ? $_[0] : lc($_[0]);
return $param_map->{$key} || $param_map->{$_[0]};
}
}
# loop below is obvious but wrong for perl
# while (@_) {$param_map->{shift(@_)}=shift(@_);}
if ($self->{case_sensitive}) {
while (@_) {
my $key=shift;
my $val=shift;
$param_map->{$key}=$val;
}
} else {
while (@_) {
my $key=shift;
my $val=shift;
if (ref($val)) {
if (UNIVERSAL::isa($val, 'ARRAY')) {
$param_map->{lc($key)}=[map {_lowercase_keys($_)} @$val];
} else {
$param_map->{lc($key)}=$val;
}
} else {
$param_map->{lc($key)}=$val;
}
}
}
}
sub register_function {
my($self, $name, $sub) = @_;
if ( ref($sub) eq 'CODE' ) {
if (ref $self) {
# per object call
$self->{expr_func}->{$name} = $sub;
$self->{expr_func_user_list}->{$name} = 1;
} else {
# per class call
$FUNC{$name} = $sub;
}
} elsif ( defined $sub ) {
croak("HTML::Template::Pro : last arg of register_function must be subroutine reference\n")
} else {
if (ref $self) {
if ( defined $name ) {
return $self->{expr_func}->{$name};
} else {
return keys %{ $self->{expr_func_user_list} };
}
} else {
return keys %FUNC;
}
}
}
sub _lowercase_keys {
my $orighash=shift;
my $newhash={};
my ($key,$val);
unless (UNIVERSAL::isa($orighash, 'HASH')) {
Carp::carp "HTML::Template::Pro:_lowercase_keys:in param_tree: found strange parameter $orighash while hash was expected";
return;
}
while (($key,$val)=each %$orighash) {
if (ref($val)) {
if (UNIVERSAL::isa($val, 'ARRAY')) {
$newhash->{lc($key)}=[map {_lowercase_keys($_)} @$val];
} else {
$newhash->{lc($key)}=$val;
}
} else {
$newhash->{lc($key)}=$val;
}
}
return $newhash;
}
# sub _load_file {
# my $filepath=shift;
# open my $fh, $filepath or die $!;
# local $/; # enable localized slurp mode
# my $content = <$fh>;
# close $fh;
# return $content;
# }
## HTML::Template based
#### callback function called from C library ##############
# Note that this _get_filepath perl code is deprecated; ##
# by default built-in find_file implementation is used. ##
# use magic option __use_perl_find_file => 1 to re-enable it.
###########################################################
sub _get_filepath {
my ($self, $filename, $last_visited_file) = @_;
# look for the included file...
my $filepath;
if ((not defined $last_visited_file) or $self->{search_path_on_include}) {
$filepath = $self->_find_file($filename);
} else {
$filepath = $self->_find_file($filename,
[File::Spec->splitdir($last_visited_file)]
);
}
carp "HTML::Template::Pro (using callback): template $filename not found!" unless $filepath;
return $filepath;
}
sub _find_file {
my ($options, $filename, $extra_path) = @_;
my $filepath;
# first check for a full path
return File::Spec->canonpath($filename)
if (File::Spec->file_name_is_absolute($filename) and (-e $filename));
# try the extra_path if one was specified
if (defined($extra_path)) {
$extra_path->[$#{$extra_path}] = $filename;
$filepath = File::Spec->canonpath(File::Spec->catfile(@$extra_path));
return File::Spec->canonpath($filepath) if -e $filepath;
}
# try pre-prending HTML_Template_Root
if (defined($ENV{HTML_TEMPLATE_ROOT})) {
$filepath = File::Spec->catfile($ENV{HTML_TEMPLATE_ROOT}, $filename);
return File::Spec->canonpath($filepath) if -e $filepath;
}
# try "path" option list..
foreach my $path (@{$options->{path}}) {
$filepath = File::Spec->catfile($path, $filename);
return File::Spec->canonpath($filepath) if -e $filepath;
}
# try even a relative path from the current directory...
return File::Spec->canonpath($filename) if -e $filename;
# try "path" option list with HTML_TEMPLATE_ROOT prepended...
if (defined($ENV{HTML_TEMPLATE_ROOT})) {
foreach my $path (@{$options->{path}}) {
$filepath = File::Spec->catfile($ENV{HTML_TEMPLATE_ROOT}, $path, $filename);
return File::Spec->canonpath($filepath) if -e $filepath;
}
}
return undef;
}
sub _load_template {
my $self = shift;
my $filepath=shift;
my $template = "";
confess("HTML::Template->new() : Cannot open file $filepath : $!")
unless defined(open(TEMPLATE, $filepath));
# read into scalar
while (read(TEMPLATE, $template, 10240, length($template))) {}
close(TEMPLATE);
$self->_call_filters(\$template) if @{$self->{filter}};
return \$template;
}
# handle calling user defined filters
sub _call_filters {
my $self = shift;
my $template_ref = shift;
my $options = $self;#->{options};
my ($format, $sub);
foreach my $filter (@{$options->{filter}}) {
croak("HTML::Template->new() : bad value set for filter parameter - must be a code ref or a hash ref.")
unless ref $filter;
# translate into CODE->HASH
$filter = { 'format' => 'scalar', 'sub' => $filter }
if (ref $filter eq 'CODE');
if (ref $filter eq 'HASH') {
$format = $filter->{'format'};
$sub = $filter->{'sub'};
# check types and values
croak("HTML::Template->new() : bad value set for filter parameter - hash must contain \"format\" key and \"sub\" key.")
unless defined $format and defined $sub;
croak("HTML::Template->new() : bad value set for filter parameter - \"format\" must be either 'array' or 'scalar'")
unless $format eq 'array' or $format eq 'scalar';
croak("HTML::Template->new() : bad value set for filter parameter - \"sub\" must be a code ref")
unless ref $sub and ref $sub eq 'CODE';
# catch errors
eval {
if ($format eq 'scalar') {
# call
$sub->($template_ref);
} else {
# modulate
my @array = map { $_."\n" } split("\n", $$template_ref);
# call
$sub->(\@array);
# demodulate
$$template_ref = join("", @array);
}
};
croak("HTML::Template->new() : fatal error occured during filter call: $@") if $@;
} else {
croak("HTML::Template->new() : bad value set for filter parameter - must be code ref or hash ref");
}
}
# all done
return $template_ref;
}
1;
__END__
=head1 NAME
HTML::Template::Pro - Perl/XS module to use HTML Templates from CGI scripts
=head1 SYNOPSIS
It is moved out and split.
See L for introduction
to HTML::Template and syntax of template files.
See L for perl interface
of HTML::Template, HTML::Template::Expr and HTML::Template::Pro.
=head1 DESCRIPTION
Original HTML::Template is written by Sam Tregar, sam@tregar.com
with contributions of many people mentioned there.
Their efforts caused HTML::Template to be mature html tempate engine
which separate perl code and html design.
Yet powerful, HTML::Template is slow, especially if mod_perl isn't
available or in case of disk usage and memory limitations.
HTML::Template::Pro is a fast lightweight C/Perl+XS reimplementation
of HTML::Template (as of 2.9) and HTML::Template::Expr (as of 0.0.7).
It is not intended to be a complete replacement,
but to be a fast implementation of HTML::Template if you don't need
querying, the extended facility of HTML::Template.
Designed for heavy upload, resource limitations, abcence of mod_perl.
HTML::Template::Pro has complete support of filters and HTML::Template::Expr's
tag EXPR="", including user-defined functions and
construction .
HTML::Template work cycle uses 2 steps. First, it loads and parse template.
Then it accepts param() calls until you call output().
output() is its second phase where it produces a page from the parsed tree
of template, obtained in the 1st step.
HTML::Template::Pro loads, parse and outputs template on fly,
when you call $tmpl->output(), in one pass. The corresponding code is
written in C and glued to Perl using Perl+XS. As a result,
comparing to HTML::Template in ordinary calls, it runs
10-25 times faster. Comparing to HTML::Template with all caching enabled
under mod_perl, it still 1-3 times faster. At that HTML::Template caching
requires considerable amount of memory (per process, shareable, or on disk)
to be permanently filled with parsed trees, whereas HTML::Template::Pro
don't consumes memory for caches and use mmap() for reading templates on disk.
Introduction to HTML::Template and syntax of template files is described
in L.
Perl interface of HTML::Template and HTML::Template::Pro is described
in L.
=head1 SEE ALSO
L, L.
Progect page is http://html-tmpl-pro.sourceforge.net
(and http://sourceforge.net/projects/html-tmpl-pro)
Original modules are L, L.
Their progect page is http://html-template.sourceforge.net
=head1 BUGS
See L
=head1 AUTHOR
I. Vlasenko, Eviy@altlinux.orgE
with contributions of
Bruni Emiliano, Einfo at ebruni.itE
Stanislav Yadykin, Etosick at altlinux.ruE
Viacheslav Sheveliov Eslavash at aha.ruE
Shigeki Morimoto Eshigeki.morimoto at mixi.co.jpE
Kirill Rebenok Ekirill at rebenok.plE
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2005-2021 by I. Yu. Vlasenko.
Pieces of code in Pro.pm and documentation of HTML::Template are
copyright (C) 2000-2002 Sam Tregar (sam@tregar.com)
The template syntax, interface conventions and a large piece of documentation
of HTML::Template::Pro are based on CPAN module HTML::Template
by Sam Tregar, sam@tregar.com.
This library is free software; you can redistribute it and/or modify it under
either the LGPL2+ or under the same terms as Perl itself, either Perl version
5.8.4 or, at your option, any later version of Perl 5 you may have available.
=cut
HTML-Template-Pro-0.9524/lib/HTML/Template/Pro/ 0000755 0000764 0000764 00000000000 14171101161 017200 5 ustar igor igor HTML-Template-Pro-0.9524/lib/HTML/Template/Pro/WrapAssociate.pm 0000644 0000764 0000764 00000005357 11603320007 022314 0 ustar igor igor package HTML::Template::Pro::WrapAssociate;
use strict;
use Carp;
use vars qw($VERSION @ISA);
sub _wrap {
my ($class, $associate_object, $is_case_sensitive, $is_strict_compatibility) = @_;
if (ref($associate_object) && UNIVERSAL::can($associate_object,'param')) {
my %hash;
if ($is_case_sensitive) {
tie %hash, $class, $associate_object;
} else {
foreach my $key ($associate_object->param()) {
$hash{lc($key)} = $associate_object->param($key);
}
}
return \%hash;
} elsif (!$is_strict_compatibility && UNIVERSAL::isa($associate_object,'HASH')) {
if ($is_case_sensitive) {
return $associate_object;
} else {
my %hash;
foreach my $key (keys(%$associate_object)) {
$hash{lc($key)} = $associate_object->{$key};
}
return \%hash;
}
} else {
Carp::croak "bad value for associate: HTML::Template::Pro->new called with associate option, containing object of type " . ref($associate_object) . " which lacks a param() method and does not look like a hash!";
}
}
sub param {
my $this = shift;
return $this->[0]->param(@_);
}
sub TIEHASH {
my ($class, $associate) = @_;
my $self=[$associate,[]];
return bless $self, $class;
};
sub FETCH {
my ($this, $key) = @_;
return $this->[0]->param($key);
}
sub EXISTS {
my ($this, $key) = @_;
return defined($this->[0]->param($key));
}
sub FIRSTKEY{
my ($this) = @_;
my @param=$this->[0]->param();
$this->[1]=\@param;
return shift @{$this->[1]};
}
sub NEXTKEY{
my ($this) = @_;
return shift @{$this->[1]};
}
sub STORE{}
sub DELETE{}
sub CLEAR{}
sub SCALAR{}
1;
__END__
#head1 NAME
HTML::Template::Pro::WrapAssociate - internal wrapper for associated objects
#head1 DESCRIPTION
Original HTML::Template has an 'associate' option, that allows to specify
an extra places whare to look for a variable value. They should have custom
'param' interface method, see L for details.
This module wraps an object with custom 'param' interface method
into a magic tied hash.
Note that this module is for internal use only.
#head1 AUTHOR
I. Vlasenko, Eviy@altlinux.orgE
#head1 COPYRIGHT AND LICENSE
Copyright (C) 2005-2009 by I. Yu. Vlasenko.
Pieces of code in Pro.pm and documentation of HTML::Template are
copyright (C) 2000-2002 Sam Tregar (sam@tregar.com)
The template syntax, interface conventions and a large piece of documentation
of HTML::Template::AssociateProWrapper are based on CPAN module HTML::Template
by Sam Tregar, sam@tregar.com.
This library is free software; you can redistribute it and/or modify it
under either the LGPL2+ or under the same terms as Perl itself,
either Perl version 5.8.4 or, at your option, any later version of Perl 5
you may have available.
#cut
HTML-Template-Pro-0.9524/lib/HTML/Template/SYNTAX.pod 0000644 0000764 0000764 00000136543 11441152634 020216 0 ustar igor igor =head1 NAME
HTML::Template::SYNTAX - syntax of html template language for HTML::Template
=head1 SYNOPSIS
This help is only on syntax of html template files.
For perl interface of HTML::Template::Pro you should see
L.
First you make a template - this is just a normal HTML file with a few
extra tags, the simplest being
For example, test.tmpl:
Test Template
My Home Directory is
My Path is set to
Now define the value for HOME and PATH, for example,
in perl it will look like
$template->param(HOME => $ENV{HOME});
$template->param(PATH => $ENV{PATH});
and process the template. If all is well in the universe
this should show something like this in your browser:
My Home Directory is /home/some/directory
My Path is set to /bin;/usr/bin
=head1 DESCRIPTION
This module attempts to make using HTML templates simple and natural.
It extends standard HTML with a few new HTML-esque tags - ,
, , , and .
(HTML::Template::Pro also supports tag.)
The file written with HTML and these new tags is called a template.
It is usually saved separate from your script - possibly even created
by someone else! Using this module you fill in the values for the
variables, loops and branches declared in the template. This allows
you to separate design - the HTML - from the data, which you generate
in the Perl script.
This module is licensed under the (L)GPL or perl license.
See the LICENSE section below for more details.
=head1 TUTORIAL
If you're new to HTML::Template, I suggest you start with the
introductory article available on the HTML::Template website:
http://html-template.sourceforge.net
=head1 MOTIVATION
It is true that there are a number of packages out there to do HTML
templates. On the one hand you have things like HTML::Embperl which
allows you freely mix Perl with HTML. On the other hand lie
home-grown variable substitution solutions. Hopefully the module can
find a place between the two.
One advantage of this module over a full HTML::Embperl-esque solution
is that it enforces an important divide - design and programming. By
limiting the programmer to just using simple variables and loops in
the HTML, the template remains accessible to designers and other
non-perl people. The use of HTML-esque syntax goes further to make
the format understandable to others. In the future this similarity
could be used to extend existing HTML editors/analyzers to support
HTML::Template.
An advantage of this module over home-grown tag-replacement schemes is
the support for loops. In my work I am often called on to produce
tables of data in html. Producing them using simplistic HTML
templates results in CGIs containing lots of HTML since the HTML
itself cannot represent loops. The introduction of loop statements in
the HTML simplifies this situation considerably. The designer can
layout a single row and the programmer can fill it in as many times as
necessary - all they must agree on is the parameter names.
For all that, I think the best thing about this module is that it does
just one thing and it does it quickly and carefully. It doesn't try
to replace Perl and HTML, it just augments them to interact a little
better. And it's pretty fast.
=head1 THE TAGS
=head2 GENERAL TAG SYNTAX
A generic HTML::Template tag that is supported by HTML::Template::Pro
looks like . Tags are case-insensitve:
is acceptable.
Single quotes can be used,
quotes can be omitted,
and option name could be often guessed as in .
template tags could be decorated as html comments
Also, as HTML::Template::Pro extension (starting from version 0.90),
template tags could also be decorated as xml
See L.
=head2 TMPL_VAR
The tag is very simple. For each tag in the
template you call $template->param(PARAMETER_NAME => "VALUE"). When
the template is output the is replaced with the VALUE text
you specified. If you don't set a parameter it just gets skipped in
the output.
Optionally you can use the "ESCAPE=HTML" option in the tag to indicate
that you want the value to be HTML-escaped before being returned from
output (the old ESCAPE=1 syntax is still supported). This means that
the ", <, >, and & characters get translated into ", <, >
and & respectively. This is useful when you want to use a
TMPL_VAR in a context where those characters would cause trouble.
Example:
">
If you called C with a value like sam"my you'll get in trouble
with HTML's idea of a double-quote. On the other hand, if you use
ESCAPE=HTML, like this:
">
You'll get what you wanted no matter what value happens to be passed in for
param. You can also write ESCAPE="HTML", ESCAPE='HTML' and ESCAPE='1'.
"ESCAPE=0" and "ESCAPE=NONE" turn off escaping, which is the default
behavior.
There is also the "ESCAPE=URL" option which may be used for VARs that
populate a URL. It will do URL escaping, like replacing ' ' with '+'
and '/' with '%2F'.
There is also the "ESCAPE=JS" option which may be used for VARs that
need to be placed within a Javascript string. All \n, \r, ' and " characters
are escaped.
You can assign a default value to a variable with the DEFAULT
attribute. For example, this will output "the devil gave me a taco"
if the "who" variable is not set.
The gave me a taco.
=head2 TMPL_LOOP
...
The tag is a bit more complicated than . The
tag allows you to delimit a section of text and give it a
name. Inside this named loop you place s. Now you pass to
C a list (an array ref) of parameter assignments (hash refs) for
this loop. The loop iterates over the list and produces output from
the text block for each pass. Unset parameters are skipped. Here's
an example:
In the template:
Name:
Job:
In the script:
$template->param(EMPLOYEE_INFO => [
{ name => 'Sam', job => 'programmer' },
{ name => 'Steve', job => 'soda jerk' },
]
);
print $template->output();
The output in a browser:
Name: Sam
Job: programmer
Name: Steve
Job: soda jerk
As you can see above the takes a list of variable
assignments and then iterates over the loop body producing output.
Often you'll want to generate a 's contents
programmatically. Here's an example of how this can be done (many
other ways are possible!):
# a couple of arrays of data to put in a loop:
my @words = qw(I Am Cool);
my @numbers = qw(1 2 3);
my @loop_data = (); # initialize an array to hold your loop
while (@words and @numbers) {
my %row_data; # get a fresh hash for the row data
# fill in this row
$row_data{WORD} = shift @words;
$row_data{NUMBER} = shift @numbers;
# the crucial step - push a reference to this row into the loop!
push(@loop_data, \%row_data);
}
# finally, assign the loop data to the loop param, again with a
# reference:
$template->param(THIS_LOOP => \@loop_data);
The above example would work with a template like:
Word:
Number:
It would produce output like:
Word: I
Number: 1
Word: Am
Number: 2
Word: Cool
Number: 3
s within s are fine and work as you would
expect. If the syntax for the C call has you stumped, here's an
example of a param call with one nested loop:
$template->param(LOOP => [
{ name => 'Bobby',
nicknames => [
{ name => 'the big bad wolf' },
{ name => 'He-Man' },
],
},
],
);
Basically, each gets an array reference. Inside the array
are any number of hash references. These hashes contain the
name=>value pairs for a single pass over the loop template.
Inside a , the only variables that are usable are the ones
from the . The variables in the outer blocks are not
visible within a template loop. For the computer-science geeks among
you, a introduces a new scope much like a perl subroutine
call. If you want your variables to be global you can use
'global_vars' option to new() described below.
=head2 TMPL_INCLUDE
This tag includes a template directly into the current template at the
point where the tag is found. The included template contents are used
exactly as if its contents were physically included in the master
template.
The file specified can be an absolute path (beginning with a '/' under
Unix, for example). If it isn't absolute, the path to the enclosing
file is tried first. After that the path in the environment variable
HTML_TEMPLATE_ROOT is tried, if it exists. Next, the "path" option is
consulted, first as-is and then with HTML_TEMPLATE_ROOT prepended if
available. As a final attempt, the filename is passed to open()
directly. See below for more information on HTML_TEMPLATE_ROOT and
the "path" option to new().
As a protection against infinitly recursive includes, an arbitrary
limit of 10 levels deep is imposed. You can alter this limit with the
"max_includes" option. See the entry for the "max_includes" option
below for more details.
For the see L
for more details.
=head2 TMPL_IF
...
The tag allows you to include or not include a block of the
template based on the value of a given parameter name. If the
parameter is given a value that is true for Perl - like '1' - then the
block is included in the output. If it is not defined, or given a
false value - like '0' - then it is skipped. The parameters are
specified the same way as with TMPL_VAR.
Example Template:
Some text that only gets displayed if BOOL is true!
Now if you call $template->param(BOOL => 1) then the above block will
be included by output.
blocks can include any valid HTML::Template
construct - VARs and LOOPs and other IF/ELSE blocks. Note, however,
that intersecting a and a is invalid.
Not going to work:
If the name of a TMPL_LOOP is used in a TMPL_IF, the IF block will
output if the loop has at least one row. Example:
This will output if the loop is not empty.
....
WARNING: Much of the benefit of HTML::Template is in decoupling your
Perl and HTML. If you introduce numerous cases where you have
TMPL_IFs and matching Perl if()s, you will create a maintenance
problem in keeping the two synchronized. I suggest you adopt the
practice of only using TMPL_IF if you can do so without requiring a
matching if() in your Perl code.
=head2 TMPL_ELSIF
...
...
...
...
WARNING: TMPL_ELSIF is a HTML::Template::Pro extension! It is
not supported in HTML::Template (as of 2.9).
=head2 TMPL_ELSE
... ...
You can include an alternate block in your TMPL_IF block by using
TMPL_ELSE. NOTE: You still end the block with , not
!
Example:
Some text that is included only if BOOL is true
Some text that is included only if BOOL is false
=head2 TMPL_UNLESS
...
This tag is the opposite of . The block is output if the
CONTROL_PARAMETER is set false or not defined. You can use
with just as you can with .
Example:
Some text that is output only if BOOL is FALSE.
Some text that is output only if BOOL is TRUE.
If the name of a TMPL_LOOP is used in a TMPL_UNLESS, the UNLESS block
output if the loop has zero rows.
This will output if the loop is empty.
....
=head2 NOTES
HTML::Template's tags are meant to mimic normal HTML tags. However,
they are allowed to "break the rules". Something like:
is not really valid HTML, but it is a perfectly valid use and will
work as planned.
The "NAME=" in the tag is optional, although for extensibility's sake I
recommend using it. Example - "" is acceptable.
If you're a fanatic about valid HTML and would like your templates
to conform to valid HTML syntax, you may optionally type template tags
in the form of HTML comments. This may be of use to HTML authors who
would like to validate their templates' HTML syntax prior to
HTML::Template processing, or who use DTD-savvy editing tools.
In order to realize a dramatic savings in bandwidth, the standard
(non-comment) tags will be used throughout this documentation.
=head1 EXPR EXTENSION
This module supports an extension to HTML::Template which allows
expressions in the template syntax which was implemented in
HTML::Template::Expr. See L for details.
Expression support includes comparisons, math operations, string
operations and a mechanism to allow you add your own functions at
runtime. The basic syntax is:
I've got a lot of bananas.
This will output "I've got a lot of bananas" if you call:
$template->param(banana_count => 100);
In your script. s also work with expressions:
I'd like to have bananas.
This will output "I'd like to have 200 bananas." with the same param()
call as above.
=head1 BASIC SYNTAX
=head2 Variables
Variables are unquoted alphanumeric strings with the same restrictions
as variable names in HTML::Template. Their values are set through
param(), just like normal HTML::Template variables. For example,
these two lines are equivalent:
=head2 Emiliano Bruni extension to Expr
original HTML::Template allows almost arbitrary chars in parameter names,
but original HTML::Template::Expr (as to 0.04) allows variables in the
'EXPR' tag to be only m![A-Za-z_][A-Za-z0-9_]*!.
With this extension, arbitrary chars can be used in variable name inside
the 'EXPR' tag if bracketed in ${}, as, for example, EXPR="${foo.bar} eq 'a'".
Note that old bracketing into {} is considered obsolete, as it will clash
with JSON assignments like A = { "key" => "val" }.
COMPATIBILITY WARNING.
Currently, this extension is not present in HTML::Template::Expr (as of 0.04).
=head2 INCLUDE extension to Expr
With this extension, you can write something like
or , or even
SECURITY WARNING.
Using of this extension with untrasted values of variables is a
potential security leak (as in
with USER_INPUT='/etc/passwd').
Omit it unless you know what you are doing.
COMPATIBILITY WARNING.
Currently, this extension is not present in HTML::Template::Expr (as of 0.04).
=head2 Constants
Numbers are unquoted strings of numbers and may have a single "." to
indicate a floating point number. For example:
String constants must be enclosed in quotes, single or double. For example:
Note that the original parser of HTML::Template::Expr is currently (0.04)
rather simple, so if you need backward compatibility all compound
expressions must be parenthesized.
Backward compatible examples:
Nevertheless, in HTML::Template::Pro, you can safely write things like
with proper priority of operations.
Pattern in a regular expression must be enclosed with "/":
=head1 COMPARISON
Here's a list of supported comparison operators:
=over 4
=item * Numeric Comparisons
=over 4
=item * E
=item * E
=item * ==
=item * !=
=item * E=
=item * E=
=item * E=E
=back
=item * String Comparisons
=over 4
=item * gt
=item * lt
=item * eq
=item * ne
=item * ge
=item * le
=item * cmp
=back
=back
=head1 MATHEMATICS
The basic operators are supported:
=over 4
=item * +
=item * -
=item * *
=item * /
=item * %
=item * ^ (not supported in HTML::Template::Expr)
=back
There are also some mathy functions. See the FUNCTIONS section below.
=head1 LOGIC
Boolean logic is available:
=over 4
=item * && (synonym: and)
=item * || (synonym: or)
=back
=head1 REGULAR EXPRESSION SUPPORT
regexp support is added to HTML::Template::Expr and
HTML::Template::Pro by Stanislav Yadykin .
Currently it is not included in official distribution of HTML::Template::Expr.
Standard regexp syntax:
=over 4
=item * =~
=item * !~
=back
=head1 FUNCTIONS
The following functions are available to be used in expressions. See
perldoc perlfunc for details.
=over 4
=item * sprintf
=item * substr (2 and 3 arg versions only)
=item * lc
=item * lcfirst
=item * uc
=item * ucfirst
=item * length
=item * defined
=item * abs
=item * atan2
=item * cos
=item * exp
=item * hex
=item * int
=item * log
=item * oct
=item * rand
=item * sin
=item * sqrt
=item * srand
=back
All functions must be called using full parenthesis. For example,
this is a syntax error:
But this is good:
=head1 EXPR: DEFINING NEW FUNCTIONS
You may also define functions of your own.
See L for details.
=begin comment
=head1 METHODS
=head2 new()
Call new() to create a new Template object:
my $template = HTML::Template->new( filename => 'file.tmpl',
option => 'value'
);
You must call new() with at least one name => value pair specifying how
to access the template text. You can use C<< filename => 'file.tmpl' >>
to specify a filename to be opened as the template. Alternately you can
use:
my $t = HTML::Template->new( scalarref => $ref_to_template_text,
option => 'value'
);
and
my $t = HTML::Template->new( arrayref => $ref_to_array_of_lines ,
option => 'value'
);
These initialize the template from in-memory resources. In almost
every case you'll want to use the filename parameter. If you're
worried about all the disk access from reading a template file just
use mod_perl and the cache option detailed below.
You can also read the template from an already opened filehandle,
either traditionally as a glob or as a FileHandle:
my $t = HTML::Template->new( filehandle => *FH, option => 'value');
The four new() calling methods can also be accessed as below, if you
prefer.
my $t = HTML::Template->new_file('file.tmpl', option => 'value');
my $t = HTML::Template->new_scalar_ref($ref_to_template_text,
option => 'value');
my $t = HTML::Template->new_array_ref($ref_to_array_of_lines,
option => 'value');
my $t = HTML::Template->new_filehandle($fh,
option => 'value');
And as a final option, for those that might prefer it, you can call new as:
my $t = HTML::Template->new(type => 'filename',
source => 'file.tmpl');
Which works for all three of the source types.
If the environment variable HTML_TEMPLATE_ROOT is set and your
filename doesn't begin with /, then the path will be relative to the
value of $HTML_TEMPLATE_ROOT. Example - if the environment variable
HTML_TEMPLATE_ROOT is set to "/home/sam" and I call
HTML::Template->new() with filename set to "sam.tmpl", the
HTML::Template will try to open "/home/sam/sam.tmpl" to access the
template file. You can also affect the search path for files with the
"path" option to new() - see below for more information.
You can modify the Template object's behavior with new(). The options
are available:
=over 4
=item Error Detection Options
=over 4
=item *
die_on_bad_params - if set to 0 the module will let you call
$template->param(param_name => 'value') even if 'param_name' doesn't
exist in the template body. Defaults to 1.
=item *
strict - if set to 0 the module will allow things that look like they
might be TMPL_* tags to get by without dieing. Example:
Would normally cause an error, but if you call new with strict => 0,
HTML::Template will ignore it. Defaults to 1.
HTML::Template::Pro always use strict => 0.
=item *
vanguard_compatibility_mode - if set to 1 the module will expect to
see s that look like %NAME% in addition to the standard
syntax. Also sets die_on_bad_params => 0. If you're not at Vanguard
Media trying to use an old format template don't worry about this one.
Defaults to 0.
vanguard_compatibility_mode is not supported in HTML::Template::Pro.
=back
=item Caching Options
HTML::Template use many caching options such as
cache, shared_cache, double_cache, blind_cache, file_cache,
file_cache_dir, file_cache_dir_mode, double_file_cache
to cache preparsed html templates.
Since HTML::Template::Pro parses and outputs templates at once,
it silently ignores those options.
=back
=item Filesystem Options
=over 4
=item *
path - you can set this variable with a list of paths to search for
files specified with the "filename" option to new() and for files
included with the tag. This list is only consulted
when the filename is relative. The HTML_TEMPLATE_ROOT environment
variable is always tried first if it exists. Also, if
HTML_TEMPLATE_ROOT is set then an attempt will be made to prepend
HTML_TEMPLATE_ROOT onto paths in the path array. In the case of a
file, the path to the including file is also tried
before path is consulted.
Example:
my $template = HTML::Template->new( filename => 'file.tmpl',
path => [ '/path/to/templates',
'/alternate/path'
]
);
NOTE: the paths in the path list must be expressed as UNIX paths,
separated by the forward-slash character ('/').
=item *
search_path_on_include - if set to a true value the module will search
from the top of the array of paths specified by the path option on
every and use the first matching template found. The
normal behavior is to look only in the current directory for a
template to include. Defaults to 0.
=back
=item Debugging Options
=over 4
=item *
debug - if set to 1 the module will write random debugging information
to STDERR. Defaults to 0.
=item *
HTML::Template use many cache debug options such as
stack_debug, cache_debug, shared_cache_debug, memory_debug.
Since HTML::Template::Pro parses and outputs templates at once,
it silently ignores those options.
=back
=item Miscellaneous Options
=over 4
=item *
associate - this option allows you to inherit the parameter values
from other objects. The only requirement for the other object is that
it have a C method that works like HTML::Template's C. A
good candidate would be a CGI.pm query object. Example:
my $query = new CGI;
my $template = HTML::Template->new(filename => 'template.tmpl',
associate => $query);
Now, C<< $template->output() >> will act as though
$template->param('FormField', $cgi->param('FormField'));
had been specified for each key/value pair that would be provided by
the C<< $cgi->param() >> method. Parameters you set directly take
precedence over associated parameters.
You can specify multiple objects to associate by passing an anonymous
array to the associate option. They are searched for parameters in
the order they appear:
my $template = HTML::Template->new(filename => 'template.tmpl',
associate => [$query, $other_obj]);
The old associateCGI() call is still supported, but should be
considered obsolete.
NOTE: The parameter names are matched in a case-insensitve manner. If
you have two parameters in a CGI object like 'NAME' and 'Name' one
will be chosen randomly by associate. This behavior can be changed by
the following option.
=item *
case_sensitive - setting this option to true causes HTML::Template to
treat template variable names case-sensitively. The following example
would only set one parameter without the "case_sensitive" option:
my $template = HTML::Template->new(filename => 'template.tmpl',
case_sensitive => 1);
$template->param(
FieldA => 'foo',
fIELDa => 'bar',
);
This option defaults to off.
NOTE: with case_sensitive and loop_context_vars the special loop
variables are available in lower-case only.
=item *
loop_context_vars - when this parameter is set to true (it is false by
default) four loop context variables are made available inside a loop:
__first__, __last__, __inner__, __odd__. They can be used with
, and to control how a loop is
output.
In addition to the above, a __counter__ var is also made available
when loop context variables are turned on.
Example:
This only outputs on the first pass.
This outputs every other pass, on the odd passes.
This outputs every other pass, on the even passes.
This outputs on passes that are neither first nor last.
This is pass number .
This only outputs on the last pass.
One use of this feature is to provide a "separator" similar in effect
to the perl function join(). Example:
and , .
Would output (in a browser) something like:
Apples, Oranges, Brains, Toes, and Kiwi.
Given an appropriate C call, of course. NOTE: A loop with only
a single pass will get both __first__ and __last__ set to true, but
not __inner__.
=item *
no_includes - set this option to 1 to disallow the tag
in the template file. This can be used to make opening untrusted
templates B less dangerous. Defaults to 0.
=item *
max_includes - set this variable to determine the maximum depth that
includes can reach. Set to 10 by default. Including files to a depth
greater than this value causes an error message to be displayed. Set
to 0 to disable this protection.
=item *
global_vars - normally variables declared outside a loop are not
available inside a loop. This option makes s like global
variables in Perl - they have unlimited scope. This option also
affects and .
Example:
This is a normal variable: .
Here it is inside the loop:
Normally this wouldn't work as expected, since 's
value outside the loop is not available inside the loop.
The global_vars option also allows you to access the values of an
enclosing loop within an inner loop. For example, in this loop the
inner loop will have access to the value of OUTER_VAR in the correct
iteration:
OUTER:
INNER:
INSIDE OUT:
B: C is not C (which does not exist).
That means that loops you declare at one scope are not available
inside other loops even when C is on.
=item *
path_like_variable_scope - this option switches on a Shigeki Morimoto
extension to HTML::Template::Pro that allows access to variables that
are outside the current loop scope using path-like expressions.
Example:
{{{
}}}
=item *
filter - this option allows you to specify a filter for your template
files. A filter is a subroutine that will be called after
HTML::Template reads your template file but before it starts parsing
template tags.
In the most simple usage, you simply assign a code reference to the
filter parameter. This subroutine will recieve a single argument - a
reference to a string containing the template file text. Here is an
example that accepts templates with tags that look like "!!!ZAP_VAR
FOO!!!" and transforms them into HTML::Template tags:
my $filter = sub {
my $text_ref = shift;
$$text_ref =~ s/!!!ZAP_(.*?)!!!//g;
};
# open zap.tmpl using the above filter
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => $filter);
More complicated usages are possible. You can request that your
filter receieve the template text as an array of lines rather than as
a single scalar. To do that you need to specify your filter using a
hash-ref. In this form you specify the filter using the C key and
the desired argument format using the C key. The available
formats are C and C. Using the C format will incur
a performance penalty but may be more convenient in some situations.
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => { sub => $filter,
format => 'array' });
You may also have multiple filters. This allows simple filters to be
combined for more elaborate functionality. To do this you specify an
array of filters. The filters are applied in the order they are
specified.
my $template = HTML::Template->new(filename => 'zap.tmpl',
filter => [
{ sub => \&decompress,
format => 'scalar' },
{ sub => \&remove_spaces,
format => 'array' }
]);
The specified filters will be called for any TMPL_INCLUDEed files just
as they are for the main template file.
=item *
default_escape - Set this parameter to "HTML", "URL" or "JS" and
HTML::Template will apply the specified escaping to all variables
unless they declare a different escape in the template.
=back
=cut
=head2 param()
C can be called in a number of ways
1) To return a list of parameters in the template :
my @parameter_names = $self->param();
2) To return the value set to a param :
my $value = $self->param('PARAM');
3) To set the value of a parameter :
# For simple TMPL_VARs:
$self->param(PARAM => 'value');
# with a subroutine reference that gets called to get the value
# of the scalar. The sub will recieve the template object as a
# parameter.
$self->param(PARAM => sub { return 'value' });
# And TMPL_LOOPs:
$self->param(LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
);
4) To set the value of a a number of parameters :
# For simple TMPL_VARs:
$self->param(PARAM => 'value',
PARAM2 => 'value'
);
# And with some TMPL_LOOPs:
$self->param(PARAM => 'value',
PARAM2 => 'value',
LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
],
ANOTHER_LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
);
5) To set the value of a a number of parameters using a hash-ref :
$self->param(
{
PARAM => 'value',
PARAM2 => 'value',
LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
],
ANOTHER_LOOP_PARAM =>
[
{ PARAM => VALUE_FOR_FIRST_PASS, ... },
{ PARAM => VALUE_FOR_SECOND_PASS, ... }
...
]
}
);
=head2 clear_params()
Sets all the parameters to undef. Useful internally, if nowhere else!
=head2 output()
output() returns the final result of the template. In most situations
you'll want to print this, like:
print $template->output();
When output is called each occurrence of is
replaced with the value assigned to "name" via C. If a named
parameter is unset it is simply replaced with ''. are
evaluated once per parameter set, accumlating output on each pass.
Calling output() is guaranteed not to change the state of the
Template object, in case you were wondering. This property is mostly
important for the internal implementation of loops.
You may optionally supply a filehandle to print to automatically as
the template is generated. This may improve performance and lower
memory consumption. Example:
$template->output(print_to => *STDOUT);
The return value is undefined when using the C option.
=head2 query()
This method allow you to get information about the template structure.
It can be called in a number of ways. The simplest usage of query is
simply to check whether a parameter name exists in the template, using
the C option:
if ($template->query(name => 'foo')) {
# do something if a varaible of any type
# named FOO is in the template
}
This same usage returns the type of the parameter. The type is the
same as the tag minus the leading 'TMPL_'. So, for example, a
TMPL_VAR parameter returns 'VAR' from C.
if ($template->query(name => 'foo') eq 'VAR') {
# do something if FOO exists and is a TMPL_VAR
}
Note that the variables associated with TMPL_IFs and TMPL_UNLESSs will
be identified as 'VAR' unless they are also used in a TMPL_LOOP, in
which case they will return 'LOOP'.
C also allows you to get a list of parameters inside a loop
(and inside loops inside loops). Example loop:
And some query calls:
# returns 'LOOP'
$type = $template->query(name => 'EXAMPLE_LOOP');
# returns ('bop', 'bee', 'example_inner_loop')
@param_names = $template->query(loop => 'EXAMPLE_LOOP');
# both return 'VAR'
$type = $template->query(name => ['EXAMPLE_LOOP', 'BEE']);
$type = $template->query(name => ['EXAMPLE_LOOP', 'BOP']);
# and this one returns 'LOOP'
$type = $template->query(name => ['EXAMPLE_LOOP',
'EXAMPLE_INNER_LOOP']);
# and finally, this returns ('inner_bee', 'inner_bop')
@inner_param_names = $template->query(loop => ['EXAMPLE_LOOP',
'EXAMPLE_INNER_LOOP']);
# for non existent parameter names you get undef
# this returns undef.
$type = $template->query(name => 'DWEAZLE_ZAPPA');
# calling loop on a non-loop parameter name will cause an error.
# this dies:
$type = $template->query(loop => 'DWEAZLE_ZAPPA');
As you can see above the C option returns a list of parameter
names and both C and C take array refs in order to refer
to parameters inside loops. It is an error to use C with a
parameter that is not a loop.
Note that all the names are returned in lowercase and the types are
uppercase.
Just like C, C with no arguments returns all the
parameter names in the template at the top level.
=head1 FREQUENTLY ASKED QUESTIONS
In the interest of greater understanding I've started a FAQ section of
the perldocs. Please look in here before you send me email.
=over 4
=item 1
Q: Is there a place to go to discuss HTML::Template and/or get help?
A: There's a mailing-list for discussing HTML::Template at
html-template-users@lists.sourceforge.net. To join:
http://lists.sourceforge.net/lists/listinfo/html-template-users
If you just want to get email when new releases are available you can
join the announcements mailing-list here:
http://lists.sourceforge.net/lists/listinfo/html-template-announce
=item 2
Q: Is there a searchable archive for the mailing-list?
A: Yes, you can find an archive of the SourceForge list here:
http://www.geocrawler.com/lists/3/SourceForge/23294/0/
For an archive of the old vm.com list, setup by Sean P. Scanlon, see:
http://bluedot.net/mail/archive/
=item 3
Q: I want support for ! How about it?
A: Maybe. I definitely encourage people to discuss their ideas for
HTML::Template on the mailing list. Please be ready to explain to me
how the new tag fits in with HTML::Template's mission to provide a
fast, lightweight system for using HTML templates.
NOTE: Offering to program said addition and provide it in the form of
a patch to the most recent version of HTML::Template will definitely
have a softening effect on potential opponents!
=item 4
Q: I found a bug, can you fix it?
A: That depends. Did you send me the VERSION of HTML::Template, a test
script and a test template? If so, then almost certainly.
If you're feeling really adventurous, HTML::Template has a publically
available Subversion server. See below for more information in the PUBLIC
SUBVERSION SERVER section.
=item 5
Q: s from the main template aren't working inside a
! Why?
A: This is the intended behavior. introduces a separate
scope for s much like a subroutine call in Perl introduces a
separate scope for "my" variables.
If you want your s to be global you can set the
'global_vars' option when you call new(). See above for documentation
of the 'global_vars' new() option.
=item 6
Q: Why do you use /[Tt]/ instead of /t/i? It's so ugly!
A: Simple - the case-insensitive match switch is very inefficient.
According to _Mastering_Regular_Expressions_ from O'Reilly Press,
/[Tt]/ is faster and more space efficient than /t/i - by as much as
double against long strings. //i essentially does a lc() on the
string and keeps a temporary copy in memory.
When this changes, and it is in the 5.6 development series, I will
gladly use //i. Believe me, I realize [Tt] is hideously ugly.
=item 7
Q: How can I pre-load my templates using cache-mode and mod_perl?
A: Add something like this to your startup.pl:
use HTML::Template;
use File::Find;
print STDERR "Pre-loading HTML Templates...\n";
find(
sub {
return unless /\.tmpl$/;
HTML::Template->new(
filename => "$File::Find::dir/$_",
cache => 1,
);
},
'/path/to/templates',
'/another/path/to/templates/'
);
Note that you'll need to modify the "return unless" line to specify
the extension you use for your template files - I use .tmpl, as you
can see. You'll also need to specify the path to your template files.
One potential problem: the "/path/to/templates/" must be EXACTLY the
same path you use when you call HTML::Template->new(). Otherwise the
cache won't know they're the same file and will load a new copy -
instead getting a speed increase, you'll double your memory usage. To
find out if this is happening set cache_debug => 1 in your application
code and look for "CACHE MISS" messages in the logs.
=item 8
Q: What characters are allowed in TMPL_* NAMEs?
A: Numbers, letters, '.', '/', '+', '-' and '_'.
=item 9
Q: How can I execute a program from inside my template?
A: Short answer: you can't. Longer answer: you shouldn't since this
violates the fundamental concept behind HTML::Template - that design
and code should be seperate.
But, inevitably some people still want to do it. If that describes
you then you should take a look at
L. Using
HTML::Template::Expr it should be easy to write a run_program()
function. Then you can do awful stuff like:
Just, please, don't tell me about it. I'm feeling guilty enough just
for writing HTML::Template::Expr in the first place.
=item 10
Q: Can I get a copy of these docs in Japanese?
A: Yes you can. See Kawai Takanori's translation at:
http://member.nifty.ne.jp/hippo2000/perltips/html/template.htm
=item 11
Q: What's the best way to create a at pos " MOD_TD "\n",TAGNAME[i], TO_PTRDIFF_T(state->cur_pos-state->top));
} else {
tmpl_log(TMPL_LOG_DEBUG, "found at pos " MOD_TD "\n",TAGNAME[i], TO_PTRDIFF_T(state->cur_pos-state->top));
}
}
break;
}
}
if (HTML_TEMPLATE_BAD_TAG==tag_type) {
state->param->found_syntax_error=1;
log_state(state,TMPL_LOG_ERROR, "found bad/unsupported tag at pos " MOD_TD "\n", TO_PTRDIFF_T(state->cur_pos-state->top));
/* TODO: flush its data --- */
state->cur_pos++;
return;
}
if (is_tag_closed && !tag_can_be_closed[tag_type]) {
state->param->found_syntax_error=1;
log_state(state,TMPL_LOG_ERROR, "incorrect closed tag at pos " MOD_TD "\n",
TAGNAME[tag_type], TO_PTRDIFF_T(state->cur_pos-state->top));
}
if (is_tag_closed || ! tag_has_opt[tag_type][TAG_OPT_NAME]) {
/* tag has no parameter */
#ifdef COMPAT_ALLOW_NAME_IN_CLOSING_TAG
/* requested compatibility mode
to try reading NAME inside
(useful for comments?) */
try_tag_parameter(state, tagopt[TAG_OPT_NAME], TAGOPT[TAG_OPT_NAME]);
read_tag_parameter_value(state);
#endif
} else {
try_tmpl_var_options(state, tag_type, TagOptVal);
/* suport for short syntax */
if (TagOptVal[TAG_OPT_NAME].begin == NULL &&
tag_has_opt[tag_type][TAG_OPT_NAME] &&
(!tag_has_opt[tag_type][TAG_OPT_EXPR] || TagOptVal[TAG_OPT_EXPR].begin == NULL )) {
TagOptVal[TAG_OPT_NAME]=read_tag_parameter_value(state);
try_tmpl_var_options(state, tag_type, TagOptVal);
}
if (TagOptVal[TAG_OPT_NAME].begin == NULL &&
tag_has_opt[tag_type][TAG_OPT_NAME] &&
(!tag_has_opt[tag_type][TAG_OPT_EXPR] || TagOptVal[TAG_OPT_EXPR].begin == NULL )) {
state->param->found_syntax_error=1;
log_state(state,TMPL_LOG_ERROR,"NAME or EXPR is required for TMPL_%s\n", TAGNAME[tag_type]);
}
for (i=MIN_TAG_OPT; i<=MAX_TAG_OPT; i++) {
if (TagOptVal[i].begin!=NULL && ! tag_has_opt[tag_type][i]) {
state->param->found_syntax_error=1;
log_state(state,TMPL_LOG_ERROR,"TMPL_%s does not support %s= option\n", TAGNAME[tag_type], TAGOPT[i]);
}
}
}
if (state->is_tag_commented) {
/* try read comment end */
/* jump_over_space(state); it should be already done :( */
jump_over_space(state);
if (state->cur_posnext_to_end-2 && '-'==*(state->cur_pos) && '-'==*(state->cur_pos+1)) {
state->cur_pos+=2;
}
}
/* template tags could also be decorated as xml */
if (!is_tag_closed && '/'==*(state->cur_pos)) state->cur_pos++;
if ('>'==*(state->cur_pos)) {
state->cur_pos++;
} else {
state->param->found_syntax_error=1;
log_state(state,TMPL_LOG_ERROR,"end tag:found %c instead of > at pos " MOD_TD "\n",
*state->cur_pos, TO_PTRDIFF_T(state->cur_pos-state->top));
}
/* flush run chars (if in SHOW mode) */
if (state->is_visible) {
(state->param->WriterFuncPtr)(state->param->ext_writer_state,state->last_processed_pos,state->tag_start);
state->last_processed_pos=state->cur_pos;
}
if (is_tag_closed) {
output_closetag_handler[tag_type](state,TagOptVal);
} else {
output_opentag_handler[tag_type](state,TagOptVal);
}
}
/* max offset to ensure we are not out of file when try Variable 1 set!Variable 1 not set!
HTML-Template-Pro-0.9524/templates-Pro/include/ 0000755 0000764 0000764 00000000000 14171101161 017532 5 ustar igor igor HTML-Template-Pro-0.9524/templates-Pro/include/4.tmpl 0000644 0000764 0000764 00000000021 10775214411 020575 0 ustar igor igor 0! HTML-Template-Pro-0.9524/templates-Pro/include/2.tmpl 0000644 0000764 0000764 00000000074 10775214411 020603 0 ustar igor igor
HTML-Template-Pro-0.9524/templates-Pro/include/1/ 0000755 0000764 0000764 00000000000 14171101161 017672 5 ustar igor igor HTML-Template-Pro-0.9524/templates-Pro/include/1/a.incl 0000644 0000764 0000764 00000000004 11252363057 020766 0 ustar igor igor A-1
HTML-Template-Pro-0.9524/templates-Pro/include/3.tmpl 0000644 0000764 0000764 00000000040 10775214411 020575 0 ustar igor igor
HTML-Template-Pro-0.9524/templates-Pro/include/2.out 0000644 0000764 0000764 00000000011 10775223777 020444 0 ustar igor igor 01!
02!
HTML-Template-Pro-0.9524/templates-Pro/include/2/ 0000755 0000764 0000764 00000000000 14171101161 017673 5 ustar igor igor HTML-Template-Pro-0.9524/templates-Pro/include/2/a.incl 0000644 0000764 0000764 00000000004 11252363071 020763 0 ustar igor igor A-2
HTML-Template-Pro-0.9524/templates-Pro/include/a.incl 0000644 0000764 0000764 00000000011 11252363036 020621 0 ustar igor igor A-PARENT
HTML-Template-Pro-0.9524/templates-Pro/test_if1.tmpl 0000644 0000764 0000764 00000001756 10617575362 020557 0 ustar igor igor
test_if1
defined (FALSE)
(if test 1) defined (TRUE)
(if test 2) defined (if test 3 level 1)
defined (if test 3 level 2)
defined (if test 3 level 3)
defined (if test 3 level 4 FALSE)
------------------ defined (TRUE)
(if test 1) defined (FALSE)
(if test 2) defined (if test 3 level 1)
defined (if test 3 level 2)
defined (if test 3 level 3)
defined (if test 3 level 4)
HTML-Template-Pro-0.9524/templates-Pro/test_expr7.tmpl 0000644 0000764 0000764 00000000555 10714321277 021131 0 ustar igor igor
test_expr7
We test inner loop variables
first:
last:
odd:
inner:
count:
HTML-Template-Pro-0.9524/templates-Pro/test_expr3.tmpl 0000644 0000764 0000764 00000000211 11230140653 021101 0 ustar igor igor
test nt aryphmetics
1+1=
2*2=
4/2=
HTML-Template-Pro-0.9524/templates-Pro/test_userfunc5.tmpl 0000644 0000764 0000764 00000000152 11236341530 021766 0 ustar igor igor
test on nested functions
HTML-Template-Pro-0.9524/templates-Pro/test_expr8.out 0000644 0000764 0000764 00000000215 10775214411 020754 0 ustar igor igor
test_expr8
We test addition
707020000100000070701
HTML-Template-Pro-0.9524/templates-Pro/test_if3.out 0000644 0000764 0000764 00000000160 10617575362 020400 0 ustar igor igor
test_if3
We test that hash/array ref should be true
test passed
HTML-Template-Pro-0.9524/templates-Pro/test_esc1.out 0000644 0000764 0000764 00000000106 11676076065 020554 0 ustar igor igor
test_esc1
&foo"bar'=-;+ \<>"; %FAhidden:
end
HTML-Template-Pro-0.9524/templates-Pro/test_expr2.out 0000644 0000764 0000764 00000000754 10617575362 020770 0 ustar igor igor
test string expr
ONE lt THREE=1
ONE gt THREE=0
ONE ne THREE=1
ONE eq THREE=0
'1' lt '3'=1
'1' gt '3'=0
'1' ne '3'=1
'1' eq '3'=0
'1' lt THREE=1
'1' gt THREE=0
'1' ne THREE=1
'1' eq THREE=0
ONE lt '3'=1
ONE gt '3'=0
ONE ne '3'=1
ONE eq '3'=0
'100' lt '3'=1
'100' lt '30'=1
'100' le '30'=1
'100' gt '30'=0
'100' ge '30'=0
100 lt '30'=1
100 lt 30=1
'aaa' le 'b'=1
'aaa' ge 'b'=0
'bbb' le 'a'=0
'bbb' ge 'a'=1
'bbb' cmp 'a'=1
'aaa' cmp 'b'=-1
ONE=1
foo=foo
HTML-Template-Pro-0.9524/templates-Pro/test_expr7.out 0000644 0000764 0000764 00000000747 10630025405 020756 0 ustar igor igor
test_expr7
We test inner loop variables
first:1
last: 0
odd:1
inner:0
count:1
first:0
last: 0
odd:0
inner:1
count:2
first:0
last: 0
odd:1
inner:1
count:3
first:0
last: 1
odd:0
inner:0
count:4
HTML-Template-Pro-0.9524/templates-Pro/test_userfunc1.tmpl 0000644 0000764 0000764 00000001131 10617575362 021776 0 ustar igor igor
registered_func('self')=
hello_string()=
arglist()=
arglist('')=
arglist('','')=
arglist('a','b')=
HTML-Template-Pro-0.9524/templates-Pro/test_loop3.out 0000644 0000764 0000764 00000000761 10617575362 020762 0 ustar igor igor
test_loop3
We test loops and nesting
LOOP1-VAR1
LOOP1-VAR2
LOOP1-VAR3
LOOP2-VAR1
LOOP2-VAR2
LOOP2-VAR3
LOOP3-VAR1
LOOP3-VAR2
LOOP3-VAR3
LOOP4-VAR1
LOOP4-VAR2
LOOP4-VAR3
VAR2 test passed
HTML-Template-Pro-0.9524/templates-Pro/test_esc1.tmpl 0000644 0000764 0000764 00000000256 10617575362 020725 0 ustar igor igor
test_esc1
HTML-Template-Pro-0.9524/templates-Pro/test_userfunc3.tmpl 0000644 0000764 0000764 00000000221 10617575046 021776 0 ustar igor igor
test_expr6 (per_object_call)
HTML-Template-Pro-0.9524/templates-Pro/test_loop4.tmpl 0000644 0000764 0000764 00000000555 10630015117 021107 0 ustar igor igor
test_loop4
We test inner loop variables
first:
last:
odd:
inner:
count:
HTML-Template-Pro-0.9524/templates-Pro/test_include1.tmpl 0000644 0000764 0000764 00000000440 10617575362 021571 0 ustar igor igor
test_include1
defined (FALSE)
undefined (TRUE), so including test_if2 ...
(include test 1)
HTML-Template-Pro-0.9524/templates-Pro/test_esc3.out 0000644 0000764 0000764 00000000144 11676076065 020560 0 ustar igor igor
test_esc3
&foo"bar'</script>=-;+ \<>"; %FAhidden:
end
HTML-Template-Pro-0.9524/templates-Pro/test_expr5.out 0000644 0000764 0000764 00000000320 11450360734 020747 0 ustar igor igor
test on string compare
true:1
false:0
false:0
false:0
false:0
false:0
false:0
false:0
testing unescape string
false:0
true:1
good
good
true:1
true:1
true:1
false:0
HTML-Template-Pro-0.9524/templates-Pro/test_include2.out 0000644 0000764 0000764 00000002404 10617575362 021427 0 ustar igor igor
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
test_include2
Before recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
After recursive include
HTML-Template-Pro-0.9524/templates-Pro/test_broken1.out 0000644 0000764 0000764 00000000006 10617575362 021257 0 ustar igor igor 'ONE>
HTML-Template-Pro-0.9524/templates-Pro/test_broken1.tmpl 0000644 0000764 0000764 00000000025 10617575362 021425 0 ustar igor igor