.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::Template::FAQ 3" .TH HTML::Template::FAQ 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME HTML::Template::FAQ \- Frequently Asked Questions about HTML::Template .SH SYNOPSIS .IX Header "SYNOPSIS" In the interest of greater understanding I've started a FAQ section of the perldocs. Please look in here before you send me email. .SH "FREQUENTLY ASKED QUESTIONS" .IX Header "FREQUENTLY ASKED QUESTIONS" .SS "Is there a place to go to discuss HTML::Template and/or get help?" .IX Subsection "Is there a place to go to discuss HTML::Template and/or get help?" There's a mailing-list for discussing HTML::Template at html\-template\-users@lists.sourceforge.net. Join at: .PP .Vb 1 \& http://lists.sourceforge.net/lists/listinfo/html\-template\-users .Ve .PP If you just want to get email when new releases are available you can join the announcements mailing-list here: .PP .Vb 1 \& http://lists.sourceforge.net/lists/listinfo/html\-template\-announce .Ve .SS "Is there a searchable archive for the mailing-list?" .IX Subsection "Is there a searchable archive for the mailing-list?" Yes, you can find an archive of the SourceForge list here: .PP .Vb 1 \& http://dir.gmane.org/gmane.comp.lang.perl.modules.html\-template .Ve .SS "I want support for ! How about it?" .IX Subsection "I want support for ! How about it?" 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. .PP 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! .SS "I found a bug, can you fix it?" .IX Subsection "I found a bug, can you fix it?" That depends. Did you send me the VERSION of HTML::Template, a test script and a test template? If so, then almost certainly. .PP If you're feeling really adventurous, HTML::Template is publicly available on GitHub (https://github.com/mpeters/html\-template). Please feel free to fork it and send me a pull request with any changes you have. .SS "s from the main template aren't working inside a ! Why?" .IX Subsection "s from the main template aren't working inside a ! Why?" This is the intended behavior. \f(CW\*(C`\*(C'\fR introduces a separate scope for \f(CW\*(C`s\*(C'\fR much like a subroutine call in Perl introduces a separate scope for \f(CW\*(C`my\*(C'\fR variables. .PP If you want your \f(CW\*(C`\*(C'\fRs to be global you can set the \&\f(CW\*(C`global_vars\*(C'\fR option when you call \f(CWnew()\fR. See above for documentation of the \f(CW\*(C`global_vars\*(C'\fR \f(CWnew()\fR option. .SS "How can I pre-load my templates using cache-mode and mod_perl?" .IX Subsection "How can I pre-load my templates using cache-mode and mod_perl?" Add something like this to your startup.pl: .PP .Vb 2 \& use HTML::Template; \& use File::Find; \& \& print STDERR "Pre\-loading HTML Templates...\en"; \& find( \& sub { \& return unless /\e.tmpl$/; \& HTML::Template\->new( \& filename => "$File::Find::dir/$_", \& cache => 1, \& ); \& }, \& \*(Aq/path/to/templates\*(Aq, \& \*(Aq/another/path/to/templates/\*(Aq \& ); .Ve .PP Note that you'll need to modify the \f(CW\*(C`return unless\*(C'\fR line to specify the extension you use for your template files \- I use \fI.tmpl\fR, as you can see. You'll also need to specify the path to your template files. .PP One potential problem: the \fI/path/to/templates/\fR must be \fBEXACTLY\fR the same path you use when you call \f(CW\*(C`HTML::Template\->new()\*(C'\fR. 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 \f(CW\*(C`cache_debug =\*(C'\fR 1> in your application code and look for "CACHE MISS" messages in the logs. .SS "What characters are allowed in TMPL_* names?" .IX Subsection "What characters are allowed in TMPL_* names?" Numbers, letters, '.', '/', '+', '\-' and '_'. .SS "How can I execute a program from inside my template?" .IX Subsection "How can I execute a program from inside my template?" 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 separate. .PP But, inevitably some people still want to do it. If that describes you then you should take a look at HTML::Template::Expr. Using HTML::Template::Expr it should be easy to write a \f(CWrun_program()\fR function. Then you can do awful stuff like: .PP .Vb 1 \& .Ve .PP Just, please, don't tell me about it. I'm feeling guilty enough just for writing HTML::Template::Expr in the first place. .SS "What's the best way to create a form element using HTML::Template?" There is much disagreement on this issue. My personal preference is to use CGI.pm's excellent \f(CWpopup_menu()\fR and \f(CWscrolling_list()\fR functions to fill in a single \f(CW\*(C`\*(C'\fR variable. .PP To some people this smacks of mixing HTML and code in a way that they hoped HTML::Template would help them avoid. To them I'd say that HTML is a violation of the principle of separating design from programming. There's no clear separation between the programmatic elements of the \f(CW\*(C`
\*(C'\fR tags and the layout of the \f(CW\*(C`\*(C'\fR tags. You'll have to draw the line somewhere \- clearly the designer can't be entirely in charge of form creation. .PP It's a balancing act and you have to weigh the pros and cons on each side. It is certainly possible to produce a \f(CW\*(C`