package SQL::Translator::Producer::TTSchema;
# -------------------------------------------------------------------
-# $Id: TTSchema.pm,v 1.10 2004-11-26 00:28:06 grommit Exp $
+# $Id: TTSchema.pm,v 1.11 2006-09-19 20:55:12 schiffbruechige Exp $
# -------------------------------------------------------------------
# Copyright (C) 2002-4 SQLFairy Authors
#
use strict;
use vars qw[ $DEBUG $VERSION @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Template;
my %tt_conf = exists $args->{tt_conf} ? %{$args->{tt_conf}} : ();
# sqlt passes the producer args for _all_ producers in, so we use this
# grep hack to test for the old usage.
+ debug(Dumper(\%tt_conf));
if ( grep /^[A-Z_]+$/, keys %$args ) {
warn "Template config directly in the producer args is deprecated."
." Please use 'tt_conf' instead.\n";
ABSOLUTE => 1, # Set so we can use from the command line sensibly
RELATIVE => 1, # Maybe the cmd line code should set it! Security!
%tt_conf,
- ) || die "Failed to initialize Template object: ".Template->error;
+ );
+ debug("Template ERROR: " . Template->error. "\n") if(!$tt);
+ $tt || die "Failed to initialize Template object: ".Template->error;
- $tt->process(
+ my $ttproc = $tt->process(
$file,
{ schema => $scma , %$tt_vars },
\$out
- ) or die "Error processing template '$file': ".$tt->error;
+ );
+ debug("ERROR: ". $tt->error. "\n") if(!$ttproc);
+ $ttproc or die "Error processing template '$file': ".$tt->error;
return $out;
};
to => "TTSchema",
producer_args => {
ttfile => "$Bin/data/template/basic.tt",
+# ttfile => "$Bin/data/template/test.tt",
tt_vars => {
foo => 'bar',
hello => 'world',
);
my $out;
lives_ok { $out = $obj->translate; } "Translate ran";
+# print STDERR "Output: $out\n";
ok $out ne "" ,"Produced something!";
local $/ = undef; # slurp
eq_or_diff $out, <DATA> ,"Output looks right";