From: Mark Addison Date: Thu, 19 Aug 2004 19:55:36 +0000 (+0000) Subject: Doc tweaks X-Git-Tag: v0.06~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f33f9d7029b19438c17ac3edf9f2d9c9ecbc3522;p=dbsrgits%2FSQL-Translator.git Doc tweaks --- diff --git a/lib/SQL/Translator/Producer/TT/Base.pm b/lib/SQL/Translator/Producer/TT/Base.pm index 4a00d1a..90446aa 100644 --- a/lib/SQL/Translator/Producer/TT/Base.pm +++ b/lib/SQL/Translator/Producer/TT/Base.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::TT::Base; # ------------------------------------------------------------------- -# $Id: Base.pm,v 1.4 2004-05-14 03:37:37 grommit Exp $ +# $Id: Base.pm,v 1.5 2004-08-19 19:55:36 grommit Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -32,7 +32,7 @@ class. use strict; use vars qw[ $VERSION @EXPORT_OK ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/; use Template; use Data::Dumper; @@ -157,11 +157,12 @@ sub tt_vars { () }; =head1 SYNOPSIS +# Create a producer using a template in the __DATA__ section. package SQL::Translator::Producer::Foo; use base qw/SQL::Translator::Producer::TT::Base/; - # Convert produce call into an object of our new class + # Convert produce call into a method call on our new class sub produce { return __PACKAGE__->new( translator => shift )->run; }; # Configure the Template object. @@ -173,7 +174,7 @@ sub tt_vars { () }; # Put template in DATA section (or use file with ttfile producer arg) __DATA__ Schema - + Database: [% schema.database %] Foo: $foo ... @@ -188,53 +189,46 @@ producers cheaply - by simply giving the template to use and sprinkling in some extra template variables and config. The 1st thing the module does is convert the produce sub routine call we get -from SQL::Translator into a method call on an object, so we can sub-class it. -This is done with the following code which B appear in B sub -classes. +from SQL::Translator into a method call on an object, which we can then +sub-class. This is done with the following code which needs to appear in B +sub classes. # Convert produce call into an object method call sub produce { return __PACKAGE__->new( translator => shift )->run; }; See L below for details. -The upshot of this is we can make new template producers by writing a template, -then creating a module that starts like this; - - package SQL::Translator::Producer::Foo; - - use base qw/SQL::Translator::Producer::TT::Base/; - - # Convert produce call into an object of our new class - sub produce { return __PACKAGE__->new( translator => shift )->run; }; - -And then over ride the hooks detailed below in L. +The upshot of this is we can make new template producers by sub classing this +base class, adding the above snippet and a template. +The module also provides a number of hooks into the templating process, +see L for details. See the L above for an example of creating a simple producer using a single template stored in the producers DATA section. =head1 SUB CLASS HOOKS -Sub-classes should override these methods to control the templating by giving +Sub-classes can override these methods to control the templating by giving the template source, adding variables and giving config to the Tempate object. =head2 tt_config sub tt_config { ( INTERPOLATE => 1 ); } -Return hash of Template config to add to the config given to the -C<< Template->new >> method. +Return hash of Template config to add to that given to the L