02 May 2011

HTML::Template 2


 <tmpl_if> กำหนดเงื่อนไขใน template
if.pl
#!c:\perl\bin\perl.exe
use HTML::Template;
my $tmpl = HTML::Template->new(filename=>'tmpl/if.tmpl');
$tmpl->param(bool=>1);
print "Content-type:text/html\n\n",$tmpl->output();

if.tmpl
<html>
<head>
    <title>if</title>
</head>
<body>
<tmpl_if name="bool">
  is true
<tmpl_else>
  is false
</tmpl_if>
</body>
</html>

<tmpl_unless> ใช้งานเหมือนกับ <tmpl_if> แต่เป็นเงื่อนไขที่ตรงกันข้าม(opposit)

0 comments:

Post a Comment