.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 turned on, 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 .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "HTML::Template::FAQ 3pm" .TH HTML::Template::FAQ 3pm "2013-10-21" "perl v5.18.1" "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 \s-1FAQ\s0 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 <\s-1TMPL_XXX\s0>! 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 \s-1HTML\s0 templates. .PP \&\s-1NOTE:\s0 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 \s-1VERSION\s0 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-1TMPL_VAR\s0>s from the main template aren't working inside a <\s-1TMPL_LOOP\s0>! 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(CW\*(C`new()\*(C'\fR. See above for documentation of the \f(CW\*(C`global_vars\*(C'\fR \f(CW\*(C`new()\*(C'\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 \fB\s-1EXACTLY\s0\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 \*(L"\s-1CACHE MISS\*(R"\s0 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(CW\*(C`run_program()\*(C'\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 \s-1CGI\s0.pm's excellent \f(CW\*(C`popup_menu()\*(C'\fR and \f(CW\*(C`scrolling_list()\*(C'\fR functions to fill in a single \f(CW\*(C`\*(C'\fR variable. .PP To some people this smacks of mixing \s-1HTML\s0 and code in a way that they hoped HTML::Template would help them avoid. To them I'd say that \s-1HTML\s0 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`