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
Tiffany(3) User Contributed Perl Documentation Tiffany(3)

Tiffany - Generic interface for Perl5 template engines.

    use Tiffany;

    my $tmpl = Tiffany->load('Text::Xslate', {syntax => 'TTerse'});
    $tmpl->render(\'Hello, [% name %]', {name => 'John'});
    # => "Hello, John"

Tiffany is a generic interface for Perl5 template engines.

Tiffany.pm acts as a factory for Tiffany::* classes, which in turn are the actual adaptor classes for each template engine.
"my $tiffany = Tiffany->load($klass, $args)"
Load Tiffany::* class if necessary, and create new instance of using the given arguments.

    my $xslate = Tiffany->load("Text::Xslate", +{syntax => 'TTerse'});

    my $xslate = Tiffany->load("+My::Template::Engine", +{option => 'here'});
    

The Tiffany protocol is based on duck typing. A template adaptor does not need to inherit from a particular class, but its API needs to adhere to the spec provided here.

In the documentation that follows, "Tiffany::Thing" represents an adaptor class.

"my $tiffanny = Tiffany::Thing->new([$args:HashRef|ArrayRef]);"
The module SHOULD have a new method.

This method creates a new instance of Tiffany module.

$args should be passed to the constructor of the template engine.

"my $result = $tmpl->render($stuff:Scalar|ScalarRef [, @args]);"
The module SHOULD have a render method.

This method should invoke the appropriate rendering method for the underlying template engine, using @args.

If the template engine found any errors, this method MUST throw an exception.

If the template engine throws any exceptions, Tiffany module SHOULD pass through the exception unaltered.

$stuff SHOULD expect a Scalar that represents the template filename. The module MAY allow a ScalarRef that holds the actual template code.

This method MUST return plain string. Do not return a blessed reference.

Example code is here: eg/sinatraish/ in distribution tar ball or <http://github.com/tokuhirom/p5-tiffany/tree/master/eg/sinatraish/>.

Is Tiffany supports JSON?
Tiffany should not support JSON. Tiffany protocol can support JSON serialize. But real web application needs more things like Content-Type. It is not supported area for Tiffany.

Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>

Any::Template, <http://github.com/rtomayko/tilt>

kazuhooku

gfx

miyagawa

lestrrat

Copyright (C) Tokuhiro Matsuno

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2022-04-09 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.