| 1 | #!perl -w |
| 2 | |
| 3 | use strictscip-perl cpan Text-Xslate v3.5.9 strict/; |
| 4 | use Test::Morescip-perl cpan Text-Xslate v3.5.9 Test/More/; |
| 5 | |
| 6 | use Text::Xslatescip-perl cpan Text-Xslate v3.5.9 Text/Xslate/; |
| 7 | use File::Copyscip-perl cpan Text-Xslate v3.5.9 File/Copy/ qw(copy move); |
| 8 | use File::Pathscip-perl cpan Text-Xslate v3.5.9 File/Path/ qw(rmtree); |
| 9 | use File::Specscip-perl cpan Text-Xslate v3.5.9 File/Spec/; |
| 10 | use libscip-perl cpan Text-Xslate v3.5.9 lib/ "t/lib"; |
| 11 | use Utilscip-perl cpan Text-Xslate v3.5.9 Util/; |
| 12 | |
| 13 | rmtree cache_dir; |
| 14 | |
| 15 | my $base; |
| 16 | my $derived; |
| 17 | my $base_c; |
| 18 | my $derived_c; |
| 19 | BEGIN { |
| 20 | my $tx = Text::Xslate->newscip-perl cpan Text-Xslate v3.5.9 Text/Xslate/new().(path => [path], cache_dir => cache_dir); |
| 21 | |
| 22 | my $fi = $tx->find_filescip-perl cpan Text-Xslate v3.5.9 Text/Xslate/find_file().('myapp/base.tx'); |
| 23 | $base = $fi->{fullpath}; |
| 24 | $base_c = $fi->{cachepath}; |
| 25 | |
| 26 | $fi = $tx->find_filescip-perl cpan Text-Xslate v3.5.9 Text/Xslate/find_file().('myapp/derived.tx'); |
| 27 | $derived = $fi->{fullpath}; |
| 28 | $derived_c = $fi->{cachepath}; |
| 29 | } |
| 30 | |
| 31 | END{ |
| 32 | movescip-perl cpan Text-Xslate v3.5.9 main/move(). "$base.save" => $base if -e "$base.save"; |
| 33 | |
| 34 | rmtree cache_dir; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | notescip-perl cpan Text-Xslate v3.5.9 main/note(). 'for files'; |
| 39 | |
| 40 | utimescip-perl cpan Text-Xslate v3.5.9 main/utime(). $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`. - 120, $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`. - 120, $base, $derived; |
| 41 | |
| 42 | { |
| 43 | # compile and cache template files. |
| 44 | my $tx = Text::Xslate->newscip-perl cpan Text-Xslate v3.5.9 Text/Xslate/new().(path => [path], cache_dir => cache_dir); |
| 45 | $tx->renderscip-perl cpan Text-Xslate v3.5.9 Text/Xslate/render().($_scip-perl cpan Text-Xslate v3.5.9 main/$_., {lang => 'Perl'}) for 'myapp/derived.tx'; |
| 46 | } |
| 47 | |
| 48 | utimescip-perl cpan Text-Xslate v3.5.9 main/utime(). $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`. - 60, $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`. - 60, $base_c, $derived_c; |
| 49 | notescip-perl cpan Text-Xslate v3.5.9 main/note(). " cache files have been created at 60 seconds ago."; |
| 50 | |
| 51 | my $tx = Text::Xslate->newscip-perl cpan Text-Xslate v3.5.9 Text/Xslate/new().(path => [path], cache_dir => cache_dir); |
| 52 | |
| 53 | movescip-perl cpan Text-Xslate v3.5.9 main/move(). $base => "$base.save"; |
| 54 | copyscip-perl cpan Text-Xslate v3.5.9 main/copy(). "$base.mod" => $base; |
| 55 | |
| 56 | utimescip-perl cpan Text-Xslate v3.5.9 main/utime(). $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`., $^Tscip-perl cpan Text-Xslate v3.5.9 main/`$^T`., $base; |
| 57 | notescip-perl cpan Text-Xslate v3.5.9 main/note(). "modify $base just now"; |
| 58 | |
| 59 | isscip-perl cpan Text-Xslate v3.5.9 main/is(). $tx->renderscip-perl cpan Text-Xslate v3.5.9 Text/Xslate/render().('myapp/derived.tx', {lang => 'Foo'}), <<'T', "modified($_)" for 1 .. 2; |
| 60 | HEAD |
| 61 | D-BEFORE |
| 62 | Modified version of base.tx |
| 63 | D-AFTER |
| 64 | FOOT |
| 65 | T |
| 66 | |
| 67 | done_testing; |