Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Template-For-All, Generic interface for perl template engines.
Perl Other
branch: master

This branch is 49 commits behind tokuhirom:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
eg/sinatraish
lib
t
xt
.gitignore
.shipit
Changes
MANIFEST.SKIP
Makefile.PL
README.mkdn

README.mkdn

NAME

Tiffany - Generic interface for Perl5 template engines.

SYNOPSIS

use Tiffany;

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

DESCRIPTION

Tiffany is generic interface for Perl5 template engines.

FACTORY METHOD

Tiffany.pm provides factory feature for Tiffany::* classes.

  • my $tfall = Tiffany->load($klass, $args)

Load Tiffany::* class and create new instance.

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

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

The Tiffany Protocol

The Tiffany protocol is based on duck typing.

  • my $tfall = Tiffany::Thing->new([$args:HashRef|ArrayRef]);

The module SHOULD have new method.

This method creates new instance of Tiffany module.

$args should pass to the constructor of template engine.

  • $tmpl->render($stuff:Scalar|ScalarRef [, @args]);

The module SHOULD have render method.

This method rendering template with @args.

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

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

$stuff SHOULD allows Str for filename. And the module MAY allows ScalarRef for text.

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

HOW TO USE IT IN MY WEB APPLICATION FRAMEWORK?

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

AUTHOR

Tokuhiro Matsuno

SEE ALSO

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

THANKS TO

kazuhooku

gfx

miyagawa

LICENSE

Copyright (C) Tokuhiro Matsuno

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

Something went wrong with that request. Please try again.