Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated Changes to note removed of Template::Plugin::Autoformat

git-svn-id: svn://svn.tt2.org/tt/Template2/trunk@1234 d5a88997-0a34-4036-9ed2-92fb5d660d91
  • Loading branch information...
commit fa886a9f60a730bee7ac27afdeed744de62a2c7c 1 parent b49bb31
@abw authored
Showing with 8 additions and 407 deletions.
  1. +8 −0 Changes
  2. +0 −218 lib/Template/Plugin/Autoformat.pm
  3. +0 −189 t/autoform.t
View
8 Changes
@@ -11,6 +11,14 @@
#========================================================================
#-----------------------------------------------------------------------
+# Version 2.21_01 - Not yet released
+#------------------------------------------------------------------------
+
+* Removed Template::Plugin::Autoformat and t/autoform.t. They're now
+ available as a separate distribution.
+
+
+#-----------------------------------------------------------------------
# Version 2.21 - 30th June 2009
#------------------------------------------------------------------------
View
218 lib/Template/Plugin/Autoformat.pm
@@ -1,218 +0,0 @@
-#============================================================= -*-Perl-*-
-#
-# Template::Plugin::Autoformat
-#
-# DESCRIPTION
-# Plugin interface to Damian Conway's Text::Autoformat module.
-#
-# AUTHORS
-# Robert McArthur <mcarthur@dstc.edu.au>
-# - original plugin code
-#
-# Andy Wardley <abw@wardley.org>
-# - added FILTER registration, support for forms and some additional
-# documentation
-#
-# COPYRIGHT
-# Copyright (C) 2000-2007 Robert McArthur, Andy Wardley.
-# All Rights Reserved.
-#
-# This module is free software; you can redistribute it and/or
-# modify it under the same terms as Perl itself.
-#
-#============================================================================
-
-package Template::Plugin::Autoformat;
-
-use strict;
-use warnings;
-use base 'Template::Plugin';
-use Text::Autoformat;
-
-our $VERSION = 2.70;
-
-sub new {
- my ($class, $context, $options) = @_;
- my $filter_factory;
- my $plugin;
-
- if ($options) {
- # create a closure to generate filters with additional options
- $filter_factory = sub {
- my $context = shift;
- my $filtopt = ref $_[-1] eq 'HASH' ? pop : { };
- @$filtopt{ keys %$options } = values %$options;
- return sub {
- tt_autoformat(@_, $filtopt);
- };
- };
-
- # and a closure to represent the plugin
- $plugin = sub {
- my $plugopt = ref $_[-1] eq 'HASH' ? pop : { };
- @$plugopt{ keys %$options } = values %$options;
- tt_autoformat(@_, $plugopt);
- };
- }
- else {
- # simple filter factory closure (no legacy options from constructor)
- $filter_factory = sub {
- my $context = shift;
- my $filtopt = ref $_[-1] eq 'HASH' ? pop : { };
- return sub {
- tt_autoformat(@_, $filtopt);
- };
- };
-
- # plugin without options can be static
- $plugin = \&tt_autoformat;
- }
-
- # now define the filter and return the plugin
- $context->define_filter('autoformat', [ $filter_factory => 1 ]);
- return $plugin;
-}
-
-sub tt_autoformat {
- my $options = ref $_[-1] eq 'HASH' ? pop : { };
- my $form = $options->{ form };
- my $out = $form ? Text::Autoformat::form($options, $form, @_)
- : Text::Autoformat::autoformat(join('', @_), $options);
- return $out;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Template::Plugin::Autoformat - Interface to Text::Autoformat module
-
-=head1 SYNOPSIS
-
- [% USE autoformat(options) %]
-
- [% autoformat(text, more_text, ..., options) %]
-
- [% FILTER autoformat(options) %]
- a block of text
- [% END %]
-
-=head1 EXAMPLES
-
- # define some text for the examples
- [% text = BLOCK %]
- Be not afeard. The isle is full of noises, sounds and sweet
- airs that give delight but hurt not.
- [% END %]
-
- # pass options to constructor...
- [% USE autoformat(case => 'upper') %]
- [% autoformat(text) %]
-
- # and/or pass options to the autoformat subroutine itself
- [% USE autoformat %]
- [% autoformat(text, case => 'upper') %]
-
- # using the autoformat filter
- [% USE autoformat(left => 10, right => 30) %]
- [% FILTER autoformat %]
- Be not afeard. The isle is full of noises, sounds and sweet
- airs that give delight but hurt not.
- [% END %]
-
- # another filter example with configuration options
- [% USE autoformat %]
- [% FILTER autoformat(left => 20) %]
- Be not afeard. The isle is full of noises, sounds and sweet
- airs that give delight but hurt not.
- [% END %]
-
- # another FILTER example, defining a 'poetry' filter alias
- [% USE autoformat %]
- [% text FILTER poetry = autoformat(left => 20, right => 40) %]
-
- # reuse the 'poetry' filter alias
- [% text FILTER poetry %]
-
- # shorthand form ('|' is an alias for 'FILTER')
- [% text | autoformat %]
-
- # using forms
- [% USE autoformat(form => '>>>>.<<<', numeric => 'AllPlaces') %]
- [% autoformat(10, 20.32, 11.35) %]
-
-=head1 DESCRIPTION
-
-The autoformat plugin is an interface to Damian Conway's C<Text::Autoformat>
-Perl module which provides advanced text wrapping and formatting.
-
-Configuration options may be passed to the plugin constructor via the
-C<USE> directive.
-
- [% USE autoformat(right => 30) %]
-
-The autoformat subroutine can then be called, passing in text items which
-will be wrapped and formatted according to the current configuration.
-
- [% autoformat('The cat sat on the mat') %]
-
-Additional configuration items can be passed to the autoformat subroutine
-and will be merged with any existing configuration specified via the
-constructor.
-
- [% autoformat(text, left => 20) %]
-
-Configuration options are passed directly to the C<Text::Autoformat> plugin.
-At the time of writing, the basic configuration items are:
-
- left left margin (default: 1)
- right right margin (default 72)
- justify justification as one of 'left', 'right', 'full'
- or 'centre' (default: left)
- case case conversion as one of 'lower', 'upper',
- 'sentence', 'title', or 'highlight' (default: none)
- squeeze squeeze whitespace (default: enabled)
-
-The plugin also accepts a C<form> item which can be used to define a
-format string. When a form is defined, the plugin will call the
-underlying C<form()> subroutine in preference to C<autoformat()>.
-
- [% USE autoformat(form => '>>>>.<<') %]
- [% autoformat(123.45, 666, 3.14) %]
-
-Additional configuration items relevant to forms can also be specified.
-
- [% USE autoformat(form => '>>>>.<<', numeric => 'AllPlaces') %]
- [% autoformat(123.45, 666, 3.14) %]
-
-These can also be passed directly to the autoformat subroutine.
-
- [% USE autoformat %]
- [% autoformat( 123.45, 666, 3.14,
- form => '>>>>.<<',
- numeric => 'AllPlaces' )
- %]
-
-See L<Text::Autoformat> for further details.
-
-=head1 AUTHORS
-
-Robert McArthur wrote the original plugin code, with some modifications and
-additions from Andy Wardley.
-
-Damian Conway wrote the L<Text::Autoformat> module which does all the clever
-stuff.
-
-=head1 COPYRIGHT
-
-Copyright (C) 2000-2007 Robert McArthur & Andy Wardley. All Rights Reserved.
-
-This module is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-L<Template::Plugin>, L<Text::Autoformat>
-
View
189 t/autoform.t
@@ -1,189 +0,0 @@
-#============================================================= -*-perl-*-
-#
-# t/autoform.t
-#
-# Template script testing the autoformat plugin.
-#
-# Written by Andy Wardley <abw@kfs.org>
-#
-# Copyright (C) 1996-2000 Andy Wardley. All Rights Reserved.
-# Copyright (C) 1998-2000 Canon Research Centre Europe Ltd.
-#
-# This is free software; you can redistribute it and/or modify it
-# under the same terms as Perl itself.
-#
-# $Id$
-#
-#========================================================================
-
-use strict;
-use warnings;
-use lib qw( ../lib );
-use Template qw( :status );
-use Template::Test;
-use POSIX qw( localeconv );
-
-$Template::Test::DEBUG = 0;
-$Template::Test::PRESERVE = 1;
-
-eval "use Text::Autoformat";
-
-if ($@) {
- skip_all('Text::Autoformat module not installed');
-}
-if ($] >= 5.008) {
- skip_all("Text::Autoformat tests unreliable under $]");
-}
-
-# for testing known bug with locales that don't use '.' as a decimal
-# separator - see TODO file.
-# POSIX::setlocale( &POSIX::LC_ALL, 'sv_SE' );
-
-my $loc = localeconv;
-my $dec = $loc->{ decimal_point };
-
-my $vars = {
- decimal => $dec,
-};
-
-test_expect(\*DATA, { POST_CHOMP => 1 }, $vars);
-
-
-#------------------------------------------------------------------------
-# test input
-#------------------------------------------------------------------------
-
-__DATA__
--- test --
-[% global.text = BLOCK %]
-This is some text which
-I would like to have formatted
-and I should ensure that it continues
-for a reasonable length
-[% END %]
-[% USE Autoformat(left => 3, right => 20) %]
-[% Autoformat(global.text) %]
--- expect --
- This is some text
- which I would like
- to have formatted
- and I should
- ensure that it
- continues for a
- reasonable length
-
--- test --
-[% USE autoformat(left=5) %]
-[% autoformat(global.text, right=30) %]
--- expect --
- This is some text which I
- would like to have
- formatted and I should
- ensure that it continues
- for a reasonable length
-
--- test --
-[% USE autoformat %]
-[% autoformat(global.text, 'more text', right=50) %]
--- expect --
-This is some text which I would like to have
-formatted and I should ensure that it continues
-for a reasonable length more text
-
--- test --
-[% USE autoformat(left=10) %]
-[% global.text | autoformat %]
--- expect --
- This is some text which I would like to have formatted and I
- should ensure that it continues for a reasonable length
-
--- test --
-[% USE autoformat(left=5) %]
-[% global.text | autoformat(right=30) %]
--- expect --
- This is some text which I
- would like to have
- formatted and I should
- ensure that it continues
- for a reasonable length
-
--- test --
-[% USE autoformat %]
-[% FILTER autoformat(right=>30, case => 'upper') -%]
-This is some more text. OK! There's no need to shout!
-> quoted stuff goes here
-> more quoted stuff
-> blah blah blah
-[% END %]
--- expect --
-THIS IS SOME MORE TEXT. OK!
-THERE'S NO NEED TO SHOUT!
-> quoted stuff goes here
-> more quoted stuff
-> blah blah blah
-
--- test --
-[% USE autoformat %]
-[% autoformat(global.text, ' of time.') %]
--- expect --
-This is some text which I would like to have formatted and I should
-ensure that it continues for a reasonable length of time.
-
--- test --
-[% USE autoformat %]
-[% autoformat(global.text, ' of time.', right=>30) %]
--- expect --
-This is some text which I
-would like to have formatted
-and I should ensure that it
-continues for a reasonable
-length of time.
-
--- test --
-[% USE autoformat %]
-[% FILTER poetry = autoformat(left => 20, right => 40) %]
- Be not afeard. The isle is full of noises, sounds and sweet
- airs that give delight but hurt not.
-[% END %]
-[% FILTER poetry %]
- I cried to dream again.
-[% END %]
-
--- expect --
- Be not afeard. The
- isle is full of
- noises, sounds and
- sweet airs that give
- delight but hurt not.
- I cried to dream
- again.
-
--- test --
-Item Description Cost
-===================================
-[% form = BLOCK %]
-<<<<<< [[[[[[[[[[[[[[[ >>>>.<<
-[% END -%]
-[% USE autoformat(form => form) %]
-[% autoformat('foo', 'The Foo Item', 123.545) %]
-[% autoformat('bar', 'The Bar Item', 456.789) %]
--- expect --
--- process --
-Item Description Cost
-===================================
-foo The Foo Item 123[% decimal %]55
-bar The Bar Item 456[% decimal %]79
-
--- test --
-[% USE autoformat(form => '>>>.<<', numeric => 'AllPlaces') %]
-[% autoformat(n)
- FOREACH n = [ 123, 34.54, 99 ] +%]
-[% autoformat(987, 654.32) %]
--- expect --
--- process --
-123[% decimal %]00
- 34[% decimal %]54
- 99[% decimal %]00
-
-987[% decimal %]00
-654[% decimal %]32
Please sign in to comment.
Something went wrong with that request. Please try again.