« blib/lib/BalanceOfPower/Commands/MilitaryAid.pm
↑ Summary
blib/lib/BalanceOfPower/Role/GameMaster.pm »
| 1 | package BalanceOfPower::Printer; | ||
| 2 | $BalanceOfPower::Printer::VERSION = '0.300010'; | ||
| 3 | use Template; | ||
| 4 | use Cwd 'abs_path'; | ||
| 5 | |||
| 6 | sub print | ||
| 7 | { | ||
| 8 | my $mode = shift; | ||
| 9 | my $world = shift; | ||
| 10 | my $template = shift; | ||
| 11 | my $vars = shift; | ||
| 12 | |||
| 13 | my $module_file_path = __FILE__; | ||
| 14 | my $root_path = abs_path($module_file_path); | ||
| 15 | $root_path =~ s/Printer\.pm//; | ||
| 16 | $root_path .= "templates"; | ||
| 17 | |||
| 18 | my $tt = Template->new({INCLUDE_PATH => "$root_path/$mode", | ||
| 19 | PLUGIN_BASE => 'Template::Plugin::Filter'}); | ||
| 20 | |||
| 21 | if(ref $world eq 'BalanceOfPower::World') | ||
| 22 | { | ||
| 23 | my %nation_codes = reverse %{$world->nation_codes}; | ||
| 24 | $vars->{'nation_codes'} = \%nation_codes; | ||
| 25 | } | ||
| 26 | my $output; | ||
| 27 | $tt->process("$template.tt", $vars, \$output) || die $tt->error . "\n"; | ||
| 28 | return $output; | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; | ||
| 32 |