File Coverage

blib/lib/OpenGuides/Template.pm
Criterion Covered Total %
statement 226 229 98.6
branch 98 106 92.4
condition 65 89 73.0
subroutine 12 12 100.0
pod 2 2 100.0
total 403 438 92.0


line stmt bran cond sub pod time code
1             package OpenGuides::Template;
2              
3 92     92   16293 use strict;
  92         104  
  92         2221  
4 92     92   274 use vars qw( $VERSION );
  92         108  
  92         3439  
5             $VERSION = '0.21';
6              
7 92     92   301 use Carp qw( croak );
  92         95  
  92         3302  
8 92     92   958 use CGI; # want to get rid of this and put the burden on the templates
  92         20091  
  92         454  
9 92     92   11697 use OpenGuides; # for $VERSION for template variable
  92         115  
  92         1927  
10 92     92   309 use OpenGuides::CGI;
  92         91  
  92         1364  
11 92     92   39339 use Template;
  92         1251222  
  92         2121  
12 92     92   456 use URI::Escape;
  92         110  
  92         4226  
13 92     92   32591 use Data::Validate::URI qw( is_web_uri );
  92         2867271  
  92         180757  
14              
15             =head1 NAME
16              
17             OpenGuides::Template - Do Template Toolkit related stuff for OpenGuides applications.
18              
19             =head1 DESCRIPTION
20              
21             Does all the Template Toolkit stuff for OpenGuides. Distributed and
22             installed as part of the OpenGuides project, not intended for
23             independent installation. This documentation is probably only useful
24             to OpenGuides developers.
25              
26             =head1 SYNOPSIS
27              
28             use OpenGuides::Config;
29             use OpenGuides::Utils;
30             use OpenGuides::Template;
31              
32             my $config = OpenGuides::Config->new( file => "wiki.conf" );
33             my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
34              
35             print OpenGuides::Template->output( wiki => $wiki,
36             config => $config,
37             template => "node.tt",
38             vars => { foo => "bar" }
39             );
40              
41             =head1 METHODS
42              
43             =over 4
44              
45             =item B
46              
47             print OpenGuides::Template->output( wiki => $wiki,
48             config => $config,
49             template => "node.tt",
50             content_type => "text/html",
51             cookies => $cookie,
52             vars => {foo => "bar"},
53             noheaders => 1
54             );
55              
56             Returns everything you need to send to STDOUT, including the
57             Content-Type: header. Croaks unless C