1 #============================================================= -*-Perl-*-
3 # Template::Plugin::Format
7 # Simple Template Toolkit Plugin which creates formatting functions.
10 # Andy Wardley <abw@wardley.org>
13 # Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
15 # This module is free software; you can redistribute it and/or
16 # modify it under the same terms as Perl itself.
18 #============================================================================
20 package Template::Plugin::Format;
24 use base 'Template::Plugin';
30 my ($class, $context, $format) = @_;;
31 return defined $format
32 ? make_formatter($format)
39 $format = '%s' unless defined $format;
42 push(@args, '') unless @args;
43 return sprintf($format, @args);
54 Template::Plugin::Format - Plugin to create formatting functions
59 [% commented = format('# %s') %]
60 [% commented('The cat sat on the mat') %]
62 [% USE bold = format('<b>%s</b>') %]
67 The format plugin constructs sub-routines which format text according to
68 a C<printf()>-like format string.
72 Andy Wardley E<lt>abw@wardley.orgE<gt> L<http://wardley.org/>
76 Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
78 This module is free software; you can redistribute it and/or
79 modify it under the same terms as Perl itself.
89 # perl-indent-level: 4
90 # indent-tabs-mode: nil
93 # vim: expandtab shiftwidth=4: