summaryrefslogtreecommitdiff
path: root/LedgerSMB/Template/PS.pm
blob: 553491136eaf64bccd86673e1295f382be86875c (plain)
  1. =head1 NAME
  2. LedgerSMB::Template::PS Template support module for LedgerSMB
  3. =head1 METHODS
  4. =over
  5. =item get_template ($name)
  6. Returns the appropriate template filename for this format.
  7. =item preprocess ($vars)
  8. Currently does nothing.
  9. =item process ($parent, $cleanvars)
  10. Processes the template for Postscript.
  11. =item postprocess ($parent)
  12. Currently does nothing.
  13. =back
  14. =head1 Copyright (C) 2007, The LedgerSMB core team.
  15. This work contains copyrighted information from a number of sources all used
  16. with permission.
  17. It is released under the GNU General Public License Version 2 or, at your
  18. option, any later version. See COPYRIGHT file for details. For a full list
  19. including contact information of contributors, maintainers, and copyright
  20. holders, see the CONTRIBUTORS file.
  21. =cut
  22. package LedgerSMB::Template::PS;
  23. use Error qw(:try);
  24. use Template::Latex;
  25. sub get_template {
  26. my $name = shift;
  27. return "${name}.tex";
  28. }
  29. sub preprocess {
  30. my $rawvars = shift;
  31. my $vars;
  32. my $type = ref $rawvars;
  33. return $vars;
  34. }
  35. sub process {
  36. my $parent = shift;
  37. my $cleanvars = shift;
  38. my $template;
  39. $template = Template::Latex->new({
  40. LATEX_FORMAT => 'ps',
  41. INCLUDE_PATH => $parent->{include_path},
  42. START_TAG => quotemeta('<?lsmb'),
  43. END_TAG => quotemeta('?>'),
  44. DELIMITER => ';',
  45. }) || throw Error::Simple Template::Latex->error();
  46. if (not $template->process(
  47. get_template($parent->{template}),
  48. $cleanvars, "$parent->{outputfile}.ps", binmode => ':utf8')) {
  49. throw Error::Simple $template->error();
  50. }
  51. $parent->{mimetype} = 'application/postscript';
  52. }
  53. sub postprocess {
  54. my $parent = shift;
  55. $parent->{rendered} = "$parent->{outputfile}.ps";
  56. return "$parent->{outputfile}.ps";
  57. }
  58. 1;