1#============================================================= -*-perl-*- 2# 3# t/process.t 4# 5# Test the PROCESS option. 6# 7# Written by Andy Wardley <abw@kfs.org> 8# 9# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved. 10# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd. 11# 12# This is free software; you can redistribute it and/or modify it 13# under the same terms as Perl itself. 14# 15# $Id$ 16# 17#======================================================================== 18 19use strict; 20use lib qw( ./lib ../lib ); 21use Template::Test; 22use Template::Service; 23 24my $dir = -d 't' ? 't/test' : 'test'; 25my $config = { 26 INCLUDE_PATH => "$dir/src:$dir/lib", 27 PROCESS => 'content', 28 TRIM => 1, 29}; 30my $tt1 = Template->new($config); 31 32$config->{ PRE_PROCESS } = 'config'; 33$config->{ PROCESS } = 'header:content'; 34$config->{ POST_PROCESS } = 'footer'; 35$config->{ TRIM } = 0; 36my $tt2 = Template->new($config); 37 38$config->{ PRE_PROCESS } = 'config:header.tt2'; 39$config->{ PROCESS } = ''; 40my $tt3 = Template->new($config); 41 42my $replace = { 43 title => 'Joe Random Title', 44}; 45 46 47test_expect(\*DATA, [ tt1 => $tt1, tt2 => $tt2, tt3 => $tt3 ], $replace); 48 49__END__ 50-- test -- 51This is the first test 52-- expect -- 53This is the main content wrapper for "untitled" 54This is the first test 55This is the end. 56 57-- test -- 58[% META title = 'Test 2' -%] 59This is the second test 60-- expect -- 61This is the main content wrapper for "Test 2" 62This is the second test 63This is the end. 64 65-- test -- 66-- use tt2 -- 67[% META title = 'Test 3' -%] 68This is the third test 69-- expect -- 70header: 71 title: Joe Random Title 72 menu: This is the menu, defined in 'config' 73This is the main content wrapper for "Test 3" 74This is the third test 75 76This is the end. 77footer 78 79-- test -- 80-- use tt3 -- 81[% META title = 'Test 3' -%] 82This is the third test 83-- expect -- 84header.tt2: 85 title: Joe Random Title 86 menu: This is the menu, defined in 'config' 87footer 88 89