Patrick,

I'm not familiar with the libraries you use in the code below but, whatever it is, I'm confident to say that it should work in Embperl. For example, if you enclosed the code below between the '[-' and '-]' and printed everything to the OUT handler, you'd have an equivalent Embperl program. That is, of course, not the way you want to do it.
Embperl will place all values that came through a POST in a hash called fdat, then, if the call is a.html?p=23, you can use $fdat{p} to get 23. I use Perl-DBI/DBD for database access. Embperl does allow you to define subroutines.
Take a look at the documentation (http://perl.apache.org/embperl/pod/doc), you'll probably find everything you need in there. Regards.


On 06/16/2003 01:55 PM, Patrick Galbraith wrote:

Hi there,

I'm in the process of trying to see if Embperl is a good templating solution, but am not sure where to start. Also, I'm wondering one simple thing. How would you use Embperl to do what regular mod perl script does... something like:

#!/usr/bin/perl

use MyLib::Util;
use MyLib::DB;
my $util = new MyLib::Util;
my $db = new MyLib::DB; # this is imaginary...
my $form = $util->getForm();

my $op = $form->{op} # form parameter from a post...

my $ops = {
        'foo1' => \&fooOp1,
        'foo2' => \&fooOp2
};

$opts->{$op}->($db,$form);

sub fooOp1 {
my ($db,$form) = @_;

print <<EOT;
lots of html tags... blah blah $form->{valuewhatever}
EOT

}

sub fooOp2 {
my ($db,$form) = @_;

$recordsorwhatever = $db->getData();

if($recordsorwhatever) {
        print "html stuff... ";
        ... loop through records...
} else {
        print "print that record isn't there... blah...";
}
}

So, this is code that display html vs. something like embperl that has logic in the content. Do you have a template that has mostly code in it and then the logic calls more content laden templates?

It's just a different approach, one that I'd like to take advantage of with what Embperl purports as it's features.

Note: we used Template::Toolkit with Slash, but I think I want something speedier. We also ran perl scripts that had a SlashDisplay that called Template::Toolkit templates.

regards,

Patrick

--
Patrick Galbraith
Senior Software Developer
[EMAIL PROTECTED]
[EMAIL PROTECTED] [EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to