Template::Provider::Amazon::S3 - Enable template toolkit to use Amazon's S3 service as a provier of templates.
version 0.009
use Template; use Template::Provider::Amazon::S3; # Specify the provider in the config for Template::Toolkit. # Note since the AWS ACCESS KEY, SECRET, and bucket name # is not provided here, it will get it from the following # Envrionmental variables: # AWS_ACCESS_KEY_ID # AWS_SECRET_ACCESS_KEY # AWS_TEMPLATE_BUCKET my $tt_config = { LOAD_TEMPLATES => [ Template::Provider::Amazon::S3->new( INCLUDE_PATH => [ 'dir1', 'dir2' ] ) ] }; my $tt = Template->new($tt_config); $tt->process('file_on_s3',$vars) || die $tt->error;
This method will return the S3 client.
This method will return the bucket that was configure in the begining.
This method will return the DateTime object of the last time the internal cache was refreshed.
Call this method to refresh the cache.
returns the object for a given key. This method take a key parameter. $obj = $self->object( key => 'some_path' );
These methods are inherited from Template::Provider and function in the same way.
$obj = $class->new( %parameters ) constructs a new instance. Accepts all the arguments as the base class L<Template::Provider>, with the following additions:
This is the Amazon Access key, if this is not provided we will try and load this from the AWS_ACCESS_KEY_ID environment variable.
This is the Amazon Secret Key, if this is not provided we will try and load this from the AWS_ACCESS_KEY_SECRET environment variable.
This is the bucket that will contain all the templates. If this it not provided we will try and get it from the AWS_TEMPLATE_BUCKET envrionement variable.
This should be an array ref to directories that will be searched for the template. This method is really naive, and just prepends each entry to the template name.
This is the number of seconds that the cache will expire. The default for this is 86400 seconds, which is 1 day. This value can also be set via the environment variable TEMPLATE_AWS_REFRESH_IN_SECONDS.
This is the options to provide to the L<CHI> cache module. This can also be set by the environment variable TEMPLATE_CACHE_OPTIONS. If using the environment variable, the values need to be L<JSON> encoded. Otherwise the value will be an in memory store. The option send is the following: { driver => 'RawMemory', global => 1 }
Note do not use the RELATIVE or the ABSOLUTE parameters, I don't know what will happen if they are used.
Gautam Dey <gdey@cpan.org>
This software is copyright (c) 2012 by Gautam Dey <gdey@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Template::Provider::Amazon::S3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Template::Provider::Amazon::S3
CPAN shell
perl -MCPAN -e shell install Template::Provider::Amazon::S3
For more information on module installation, please visit the detailed CPAN module installation guide.