summaryrefslogtreecommitdiff
path: root/LedgerSMB/Template/HTML.pm
blob: d052319dbd72e778402b39b71b96dcece5f23f05 (plain)
  1. =head1 NAME
  2. LedgerSMB::Template::HTML Template support module for LedgerSMB
  3. =head1 METHODS
  4. =over
  5. =item get_template ()
  6. Returns the appropriate template filename for this format.
  7. =item preprocess ($vars)
  8. This method returns a reference to a hash that contains a copy of the passed
  9. hashref's data with HTML entities converted to escapes.
  10. =item postprocess ()
  11. Currently does nothing.
  12. =back
  13. =head1 Copyright (C) 2007, The LedgerSMB core team.
  14. This work contains copyrighted information from a number of sources all used
  15. with permission.
  16. It is released under the GNU General Public License Version 2 or, at your
  17. option, any later version. See COPYRIGHT file for details. For a full list
  18. including contact information of contributors, maintainers, and copyright
  19. holders, see the CONTRIBUTORS file.
  20. =cut
  21. package LedgerSMB::Template::HTML;
  22. use Error qw(:try);
  23. use CGI;
  24. sub get_template {
  25. my $name = shift;
  26. return "${name}.html";
  27. }
  28. sub preprocess {
  29. my $rawvars = shift;
  30. my $vars;
  31. my $type = ref $rawvars;
  32. #XXX fix escaping function
  33. if ( $type eq 'ARRAY' ) {
  34. for (@{$rawvars}) {
  35. push @{$vars}, preprocess( $_ );
  36. }
  37. }
  38. elsif ( $type eq 'HASH' ) {
  39. for ( keys %{$rawvars} ) {
  40. $vars->{$_} = preprocess( $rawvars->{$_} );
  41. }
  42. }
  43. else {
  44. return CGI::escapeHTML($rawvars);
  45. }
  46. return $vars;
  47. }
  48. sub postprocess {
  49. my $parent = shift;
  50. return;
  51. }
  52. 1;