.\" 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::Context 3pm" .TH Tenjin::Context 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::Context \- In charge of managing variables passed to Tenjin templates. .SH "VERSION" .IX Header "VERSION" version 0.070001 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # this module is used internally, but if you insist, it is \& # in charge of the context object: \& \& # in your templates (unnecessary, for illustration purposes): \& [== $_context\->{title} =] \& # instead use: \& [== $title =] .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is in charge of managing Perl variables that are passed to templates upon rendering for direct usage. The context object is simply a hash-ref of key-value pairs, which are made available for templates as \*(L"standalone variables\*(R" named for each key in the hash-ref. .PP This module is also in charge of the actual rendering of the templates, or more correctly, for evaluating the Perl code created from the templates, first integrating the context variables to them, and returning the rendered output. .PP Finally, this module makes the Tenjin utility methods of Tenjin::Util available natively inside templates. See Tenjin::Util for more info. .SH "INTERNAL METHODS" .IX Header "INTERNAL METHODS" .SS "new( [\e%vars] )" .IX Subsection "new( [%vars] )" Constructs a new context object, which is basically a hash-ref of key-value pairs which are passed to templates as variables. If a \f(CW$vars\fR hash-ref is passed to the constructor, it will be augmented into the created object. .PP To illustrate the context object, suppose it looks like so: .PP .Vb 5 \& { \& scalar => \*(AqI am a scalar\*(Aq, \& arrayref => [qw/I am an array/], \& hashref => { i => \*(Aqam\*(Aq, a => \*(Aqhash\-ref\*(Aq }, \& } .Ve .PP Then the variables \f(CW$scalar\fR, \f(CW$arrayref\fR and \f(CW$hashref\fR will be available for direct usage inside your templates, and you can dereference the variables normally (i.e. \f(CW@$arrayref\fR and \f(CW%$hashref\fR). .ie n .SS "evaluate( $script, $template_name )" .el .SS "evaluate( \f(CW$script\fP, \f(CW$template_name\fP )" .IX Subsection "evaluate( $script, $template_name )" This method receives a compiled template and actually performes the evaluation the renders it, then returning the rendered output. If Tenjin is configured to \f(CW\*(C`use strict\*(C'\fR, the script will be \f(CW\*(C`eval\*(C'\fRed under \f(CW\*(C`use strict\*(C'\fR. .ie n .SS "to_func( $script, [$filename] )" .el .SS "to_func( \f(CW$script\fP, [$filename] )" .IX Subsection "to_func( $script, [$filename] )" This method receives the script created when reading a template and wraps it in a subroutine, \f(CW\*(C`eval\*(C'\fRs it and returns the rendered output. This method is called when compiling the template. .SS "\fI_build_decl()\fP" .IX Subsection "_build_decl()" This method is in charge of making all the key-value pairs of the context object available to templates directly by the key names. This is simply done by traversing the key-value pairs of the context object and adding an assignment line between a scalar variable named as the key and its appropriate value. .SH "UTILITY METHODS" .IX Header "UTILITY METHODS" These methods are defined in Tenjin::Util and used here so they are made available natively inside templates. See Tenjin::Util for more information. .ie n .SS "_p( $expr )" .el .SS "_p( \f(CW$expr\fP )" .IX Subsection "_p( $expr )" .ie n .SS "_P( $expr )" .el .SS "_P( \f(CW$expr\fP )" .IX Subsection "_P( $expr )" .ie n .SS "escape( $expr )" .el .SS "escape( \f(CW$expr\fP )" .IX Subsection "escape( $expr )" .ie n .SS "escape_xml( $expr )" .el .SS "escape_xml( \f(CW$expr\fP )" .IX Subsection "escape_xml( $expr )" .ie n .SS "unescape_xml( $expr )" .el .SS "unescape_xml( \f(CW$expr\fP )" .IX Subsection "unescape_xml( $expr )" .ie n .SS "encode_url( $url )" .el .SS "encode_url( \f(CW$url\fP )" .IX Subsection "encode_url( $url )" .ie n .SS "decode_url( $url )" .el .SS "decode_url( \f(CW$url\fP )" .IX Subsection "decode_url( $url )" .ie n .SS "checked( $expr )" .el .SS "checked( \f(CW$expr\fP )" .IX Subsection "checked( $expr )" .ie n .SS "selected( $expr )" .el .SS "selected( \f(CW$expr\fP )" .IX Subsection "selected( $expr )" .ie n .SS "disabled( $expr )" .el .SS "disabled( \f(CW$expr\fP )" .IX Subsection "disabled( $expr )" .ie n .SS "nl2br( $text )" .el .SS "nl2br( \f(CW$text\fP )" .IX Subsection "nl2br( $text )" .ie n .SS "text2html( $text )" .el .SS "text2html( \f(CW$text\fP )" .IX Subsection "text2html( $text )" .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 )" .SH "SEE ALSO" .IX Header "SEE ALSO" Tenjin, Tenjin::Util, Tenjin::Template. .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