.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" 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" '' '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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" 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 "Tenjin::Util 3pm" .TH Tenjin::Util 3pm "2011-03-29" "perl v5.12.4" "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" Tenjin::Util \- Utility methods for Tenjin. .SH "VERSION" .IX Header "VERSION" version 0.070001 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& # in your templates: \& \& # encode a URL \& [== encode_url(\*(Aqhttp://www.google.com/search?q=tenjin&ie=utf\-8&oe=utf\-8&aq=t\*(Aq) =] \& # returns http%3A//www.google.com/search%3Fq%3Dtenjin%26ie%3Dutf\-8%26oe%3Dutf\-8%26aq%3Dt \& \& # escape a string of lines of HTML code \& You & Me\en

Me & You

\*(Aq; ?> \& [== text2html($string) =] \& # returns <h1>You & Me</h1>
\en<h2>Me & You</h2> .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a few utility functions which can be used in your templates for your convenience. These include functions to (un)escape and (en/de)code URLs. .SH "METHODS" .IX Header "METHODS" .ie n .SS "expand_tabs( $str, [$tabwidth] )" .el .SS "expand_tabs( \f(CW$str\fP, [$tabwidth] )" .IX Subsection "expand_tabs( $str, [$tabwidth] )" Receives a string that might contain tabs in it, and replaces those tabs with spaces, each tab with the number of spaces defined by \f(CW$tabwidth\fR, or, if \f(CW$tabwidth\fR was not passed, with 8 spaces. .ie n .SS "escape_xml( $str )" .el .SS "escape_xml( \f(CW$str\fP )" .IX Subsection "escape_xml( $str )" Receives a string of \s-1XML\s0 (or (x)HTML) code and converts the characters <>&\e' to \s-1HTML\s0 entities. This is the method that is invoked when you use [= \f(CW$expression\fR =] in your templates. .ie n .SS "unescape_xml( $str )" .el .SS "unescape_xml( \f(CW$str\fP )" .IX Subsection "unescape_xml( $str )" Receives a string of escaped \s-1XML\s0 (or (x)HTML) code (for example, a string that was escaped with the \fIescape_xml()\fR function, and 'unescapes' all \s-1HTML\s0 entities back to their actual characters. .ie n .SS "encode_url( $url )" .el .SS "encode_url( \f(CW$url\fP )" .IX Subsection "encode_url( $url )" Receives a \s-1URL\s0 and encodes it by escaping 'non\-standard' characters. .ie n .SS "decode_url( $url )" .el .SS "decode_url( \f(CW$url\fP )" .IX Subsection "decode_url( $url )" Does the opposite of \fIencode_url()\fR. .ie n .SS "checked( $val )" .el .SS "checked( \f(CW$val\fP )" .IX Subsection "checked( $val )" Receives a value of some sort, and if it is a true value, returns the string \&' checked=\*(L"checked\*(R"' which can be appended to \s-1HTML\s0 checkboxes. .ie n .SS "selected( $val )" .el .SS "selected( \f(CW$val\fP )" .IX Subsection "selected( $val )" Receives a value of some sort, and if it is a true value, returns the string \&' selected=\*(L"selected\*(R"' which can be used in an option in an \s-1HTML\s0 select box. .ie n .SS "disabled( $val )" .el .SS "disabled( \f(CW$val\fP )" .IX Subsection "disabled( $val )" Receives a value of some sort, and if it is a true value, returns the string \&' disabled=\*(L"disabled\*(R"' which can be used in an \s-1HTML\s0 input. .ie n .SS "nl2br( $text )" .el .SS "nl2br( \f(CW$text\fP )" .IX Subsection "nl2br( $text )" Receives a string of text containing lines delimited by newline characters (\en, or possibly \er\en) and appends an \s-1HTML\s0 line break (
) to every line (the newline character is left untouched). .ie n .SS "text2html( $text )" .el .SS "text2html( \f(CW$text\fP )" .IX Subsection "text2html( $text )" Receives a string of text containing lines delimited by newline characters, and possibly some \s-1XML\s0 (or (x)HTML) code, escapes that code with \&\fIescape_xml()\fR and then appends an \s-1HTML\s0 line break to every line with \fInl2br()\fR. .ie n .SS "tagattr( $name, $expr, [$value] )" .el .SS "tagattr( \f(CW$name\fP, \f(CW$expr\fP, [$value] )" .IX Subsection "tagattr( $name, $expr, [$value] )" .ie n .SS "tagattrs( %attrs )" .el .SS "tagattrs( \f(CW%attrs\fP )" .IX Subsection "tagattrs( %attrs )" .ie n .SS "new_cycle( @items )" .el .SS "new_cycle( \f(CW@items\fP )" .IX Subsection "new_cycle( @items )" Creates a subroutine reference that can be used for cycling through the items of the \f(CW@items\fR array. So, for example, you can: .PP .Vb 5 \& my $cycle = new_cycle(qw/red green blue/); \& print $cycle\->(); # prints \*(Aqred\*(Aq \& print $cycle\->(); # prints \*(Aqgreen\*(Aq \& print $cycle\->(); # prints \*(Aqblue\*(Aq \& print $cycle\->(); # prints \*(Aqred\*(Aq again .Ve .SH "INTERNAL(?) METHODS" .IX Header "INTERNAL(?) METHODS" .ie n .SS "_p( $expression )" .el .SS "_p( \f(CW$expression\fP )" .IX Subsection "_p( $expression )" Wraps a Perl expression in a customized wrapper which will be processed by the Tenjin preprocessor and replaced with the standard [== \f(CW$expression\fR =]. .ie n .SS "_P( $expression )" .el .SS "_P( \f(CW$expression\fP )" .IX Subsection "_P( $expression )" Wrap a Perl expression in a customized wrapper which will be processed by the Tenjin preprocessor and replaced with the standard [= \f(CW$expression\fR =], which means the expression will be escaped. .ie n .SS "_decode_params( $s )" .el .SS "_decode_params( \f(CW$s\fP )" .IX Subsection "_decode_params( $s )" .SH "SEE ALSO" .IX Header "SEE ALSO" Tenjin, Tenjin::Template, Tenjin::Context. .SH "AUTHOR" .IX Header "AUTHOR" The \s-1CPAN\s0 version of Tenjin was forked by Ido Perlmuter from version 0.0.2 of the original plTenjin, which is developed by Makoto Kuwata at http://www.kuwata\-lab.com/tenjin/ . .PP Development of Tenjin is done with github at . .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Tenjin is licensed under the \s-1MIT\s0 license. .PP .Vb 1 \& Copyright (c) 2007\-2010 the aforementioned authors. \& \& Permission is hereby granted, free of charge, to any person obtaining \& a copy of this software and associated documentation files (the \& "Software"), to deal in the Software without restriction, including \& without limitation the rights to use, copy, modify, merge, publish, \& distribute, sublicense, and/or sell copies of the Software, and to \& permit persons to whom the Software is furnished to do so, subject to \& the following conditions: \& \& The above copyright notice and this permission notice shall be \& included in all copies or substantial portions of the Software. \& \& THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, \& EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF \& MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND \& NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE \& LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION \& OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION \& WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. .Ve