GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Tenjin::Context(3) User Contributed Perl Documentation Tenjin::Context(3)

Tenjin::Context - In charge of managing variables passed to Tenjin templates.

version 0.070001

        # this module is used internally, but if you insist, it is
        # in charge of the context object:

        # in your templates (unnecessary, for illustration purposes):
        <title>[== $_context->{title} =]</title>
        # instead use:
        <title>[== $title =]</title>

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 "standalone variables" named for each key in the hash-ref.

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.

Finally, this module makes the Tenjin utility methods of Tenjin::Util available natively inside templates. See Tenjin::Util for more info.

Constructs a new context object, which is basically a hash-ref of key-value pairs which are passed to templates as variables. If a $vars hash-ref is passed to the constructor, it will be augmented into the created object.

To illustrate the context object, suppose it looks like so:

        {
                scalar          => 'I am a scalar',
                arrayref        => [qw/I am an array/],
                hashref =>      { i => 'am', a => 'hash-ref' },
        }

Then the variables $scalar, $arrayref and $hashref will be available for direct usage inside your templates, and you can dereference the variables normally (i.e. @$arrayref and %$hashref).

This method receives a compiled template and actually performes the evaluation the renders it, then returning the rendered output. If Tenjin is configured to "use strict", the script will be "eval"ed under "use strict".

This method receives the script created when reading a template and wraps it in a subroutine, "eval"s it and returns the rendered output. This method is called when compiling the template.

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.

These methods are defined in Tenjin::Util and used here so they are made available natively inside templates. See Tenjin::Util for more information.

Tenjin, Tenjin::Util, Tenjin::Template.

The CPAN version of Tenjin was forked by Ido Perlmuter <ido at ido50.net> from version 0.0.2 of the original plTenjin, which is developed by Makoto Kuwata at <http://www.kuwata-lab.com/tenjin/>.

Development of Tenjin is done with github at <http://github.com/ido50/Tenjin>.

Tenjin is licensed under the MIT license.

        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.
2011-03-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.