From: Allen Day Date: Tue, 10 Feb 2004 06:30:06 +0000 (+0000) Subject: individual tables now returned as a hash of separate tt2 templates, keyed X-Git-Tag: v0.06~201 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc0cf6eb3fd834945a1cd64ef0e5b6bd55f913f4;p=dbsrgits%2FSQL-Translator.git individual tables now returned as a hash of separate tt2 templates, keyed by table name. --- diff --git a/lib/SQL/Translator/Producer/Turnkey.pm b/lib/SQL/Translator/Producer/Turnkey.pm index 8420398..12df9c3 100644 --- a/lib/SQL/Translator/Producer/Turnkey.pm +++ b/lib/SQL/Translator/Producer/Turnkey.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::Turnkey; # ------------------------------------------------------------------- -# $Id: Turnkey.pm,v 1.22 2004-02-09 23:02:17 kycl4rk Exp $ +# $Id: Turnkey.pm,v 1.23 2004-02-10 06:30:06 allenday Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -22,7 +22,7 @@ package SQL::Translator::Producer::Turnkey; use strict; use vars qw[ $VERSION $DEBUG ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.22 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.23 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -148,23 +148,36 @@ sub translateForm { my $t = shift; my $meta = shift; - -#"Node Data:\n"; -#warn Dumper $meta->{nodes}; -#exit; - my $args = $t->producer_args; my $type = $meta->{'template'}; - my $tt2; - $tt2 = template($type); + my $template = Template->new({ - PRE_CHOMP => 1, - POST_CHOMP => 0, - EVAL_PERL => 1 - }); + PRE_CHOMP => 1, + POST_CHOMP => 0, + EVAL_PERL => 1 + }); + my $tt2; + $tt2 = template($type); my $result; - $template->process(\$tt2, $meta, \$result) || die $template->error(); + + if($type eq 'atomtemplate'){ + my %result; + foreach my $node (values %{ $meta->{'nodes'} }){ + $result = ''; + my $param = { node => $node }; + $template->process(\$tt2, $param, \$result) || die $template->error(); + $result =~ s/^\s*(.+)\s*$/$1/s; + next unless $result; +warn "**********".$node->table->name; + $result{$node->table->name} = $result; +warn $result; + } + return %result; + } else { + $template->process(\$tt2, $meta, \$result) || die $template->error(); + } + return($result); } @@ -590,61 +603,59 @@ EOF [- FOREACH node = nodes -] [- IF !node.value.is_trivial_link -] [% CASE '[- format_table(node.key) -]' %] - [% render[- format_table(node.key) -]Atom(atom,dbobject) %] + [% INCLUDE [- format_table(node.key) -] %] [- END -] [- END -] [% CASE DEFAULT %] [% renderlist(atom.render(dbobject)) %] [% END %] -[- FOREACH node = nodes -] -[- IF !node.value.is_trivial_link -] -[% MACRO render[- format_table(node.key) -]Atom(atom, dbobject) BLOCK %] - [% lstArr = atom.render(dbobject) %] - [% rowcount = 0 %] - [% IF atom.focus == "yes" %] - [% FOREACH record = lstArr %] - [% fields = record.data %] - [- pname = format_table(node.key) -] - [- pkey = "Turnkey::Model::${pname}" -] - [- FOREACH field = node.value.data_fields -] - [- IF field != "1" -] - [- field -][% obj2link(fields.[- field -]) %] - [- END -] - [- END -] - [- FOREACH field = node.value.edges -] - [- NEXT IF field.type != 'import' -] - [- field.thisfield.name -][% obj2link(fields.[- field.thisfield.name -]) %] - [- END -] - [% id = record.id %] - [% IF (rowcount > 1) %]
[% END %] - [% rowcount = rowcount + 1 %] - [% END %] - [% ELSE %] -