Re: Multiple queries to populate drop down list boxes. Updated

Mark Haney <MarkH-rOuQeLG7NUhWk0Htik3J/[email protected]> Thu, 4 Oct 2012 18:03:22 +0000
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
Just to make absolutely sure I was getting all the variable data, I did a DataDump on $vars which is the variable that passes all the data to the template.  This is what it has in it:
markh@ubuhost:~$ cat /tmp/shifts.info
$VAR1 = \{
            'shifts' => \[
                            [
                              'First'
                            ],
                            [
                              'Second'
                            ],
                            [
                              'third'
                            ],
                            [
                              'weekend'
                            ]
                          ],
            'factories' => [
                             {
                               'abbr' => 'AB',
                               'id' => '1'
                             },
                             {
                               'abbr' => 'EBM',
                               'id' => '2'
                             },
                             {
                               'abbr' => 'QEM',
                               'id' => '3'
                             }
                           ],
            'cgi' => bless( {
                              '.parameters' => [],
                              'use_tempfile' => 1,
                              '.charset' => 'ISO-8859-1',
                              '.fieldnames' => {},
                              'param' => {},
                              'escape' => 1
                            }, 'CGI' )
          };
markh@ubuhost:~$

So, I know the data is at least getting  sent to the template, now it appears I have to look at the template code to see what's wrong.

I'm not even sure where to go with this now.  I found the Dumper::Dump template module and used it to see what was being sent to the html template.  I get all the 'factories' data but NONE of the 'shifts' data.  So, now I know where the problem is, but for the life of me don't know where to begin looking?  This doesn't seem to be a TT issue, but maybe more perl related.  Would it make sense to holler to the perl list?

At this point, what I know is the problem lies somwehere in HERE: Any, even the most insane idea, I'll take now.  I'm just lost here.


########## Rendering code for the page ################

    my $file = 'templates/shift_rpt.html';
    my $vars = {
    #'cgi' =>CGI->new(),
    'factories' => \@rows_factory,  # This moves the data from the array into a var that gets carried into the template
    'shifts' => \$row_shift # This moves the custom shifts names into the dropdown box for the reports
    };

    open (FILE, "> /tmp/shifts.info") or die "can't open shifts.info: $!";
    print FILE Data::Dumper->Dump([\$vars]);
    close FILE or die "can't close file: $!";
    print "Content-type: text/html\n\n";


    my $template = Template->new({
    # where to find template files
    INCLUDE_PATH => ['/home/markh/work/epic.git/code/embmon-web/src', '/home/markh/work/epic.git/code/embmon-web/lib'],
    # pre-process lib/config to define any extra values
    PRE_PROCESS  => ['config']
    });

    $template->process($file, $vars)
        || die "Template process failed: ", $template->error(), "\n";




--

Mark Haney
Software Developer/Consultant
AB Emblem
markh-rOuQeLG7NUhWk0Htik3J/[email protected]
Linux marius.homelinux.org 3.5.1-1.fc17.x86_64 GNU/Linux

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates