[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Proposed patch to CGI::Application


Hi Douglas,

I am guessing that the difference in what you're doing is that you have a different instance script for client, and that there is a template directory in the same position relative to each instance script, no?

i.e.

client_1/
   |_ cgi-bin/
       |_ myscript.pl
   |_ tmpl/
client_2/
   |_ cgi-bin/
       |_ myscript.pl
   |_tmpl/

That is a valid approach, but I would rather encapsulate all of the logic for choosing different clients within MyApp itself. The strongest argument in favor of this approach (IMHO) is that you can then write unit tests to ensure that you call the write templates given a predefined input parameter.

Thanks,
Chris

Douglas Kirkland wrote:

On Wednesday 09 April 2003 11:20 am, Chris Brooks wrote:
Hi Joern,

Hmm. Please correct me if I paraphrase your solution incorrectly: essentially you're suggesting that I could test for the existence of the desired template file during new(). Is that correct? The problem with this is that I don't know which template file I want to call until after I execute the appropriate run mode.

Your method would work if I checked for the existence of the file within each run mode, but I think in that case it would be less obtrusive to simply pass the default directory as load_tmpl( 'desired_template', path => '/path/to/templates/default' ). My intent is to be able to define the default template directory a single time, and then allow HTML::Template to DTRT.


Here is what I do to solve this problem.

sub setup {
   my $self = shift;
   $self->tmpl_path('../tmpl');
<snip>
}

sub main_page {
   my $self = shift;
   my $template = $self->load_tmpl('post_main.tmpl');
<snip>
}

I hope I understood what you are asking.


Douglas Kirkland

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed





---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.