File Coverage

blib/lib/Rex/Template/TT.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4             # vim: set ts=3 sw=3 tw=0:
5             # vim: set expandtab:
6              
7             =head1 NAME
8              
9             Rex::Template::TT - Use Template::Toolkit with Rex
10              
11             =head1 DESCRIPTION
12              
13             This module enables the use of Template::Toolkit for Rex Templates.
14              
15             =head1 USAGE
16              
17             Just include the file into your I.
18              
19             # Rexfile
20             use Rex::Template::TT;
21            
22             task prepare => sub {
23            
24             file "/a/file/on/the/remote/machine.conf",
25             content => template("path/to/your/template.tt",
26             var1 => $var1,
27             arr1 => \@arr1,
28             hash1 => \%hash1,
29             );
30            
31             };
32              
33             =cut
34            
35             package Rex::Template::TT;
36              
37 1     1   2299 use strict;
  1         3  
  1         38  
38 1     1   6 use warnings;
  1         2  
  1         47  
39              
40             our $VERSION = "0.33.1";
41              
42 1     1   14175 use Template;
  1         49613  
  1         41  
43              
44 1     1   720 use Rex -base;
  0            
  0            
45              
46             sub import {
47              
48             set template_function => sub {
49             my ($content, $vars) = @_;
50             my $t = Template->new;
51             my $out;
52             $t->process(\$content, $vars, \$out);
53             return $out;
54             };
55              
56             }
57              
58             1;