Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Browser-viewable HTML::Template templates

by cLive ;-) (Prior)
on Jan 12, 2003 at 08:50 UTC ( [id://226231]=note: print w/replies, xml ) Need Help??


in reply to Browser-viewable HTML::Template templates

Why not write a quick CGI script to display a template?
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Carp 'fatalsToBrowser'; my $template_dir = '/path/to/template_dir'; my $q=CGI->new(); if ( $q->param() ) { show_template(); } else { show_form(); } sub show_template { my $template = $q->param('template'); open(TMPL,"$template_dir/$template") || die $!; my $content = join '',(<TMPL>); close(TMPL); $content =~ s/<TMPL[^>]*>//gs; print $q->header(), $content; exit(0); } sub show_form { print $q->header, $q->start_html, $q->start_form, 'Template: ', $q->textfield('template'), $q->submit, $q->end_form, $q->end_html; exit(0); }

That way, you can set up a checkbox like this:

<input type="checkbox" name="foo" <TMP_VAR NAME=FOOCHECKED>>

where FOOCHECKED is either '' or 'checked'

Note - obviously I assume here you know how to taint check if this is on a live server (or to use an IP check to limit access etc) - this is just a rough outline.

.02

cLive ;-)

Replies are listed 'Best First'.
Re^2: Browser-viewable HTML::Template templates
by Aristotle (Chancellor) on Jan 12, 2003 at 14:48 UTC
    Good suggestion. I think it's easier not to duplicate HTML::Template's parsing if you already have it on hand though:
    sub show_template { my $t_file = $q->param('template'); require HTML::Template; my $t = HTML::Template->new_file($t_file); # and don't fill in any values print $q->header(), $t->output; exit(0); }

    Makeshifts last the longest.

Re: Re: Browser-viewable HTML::Template templates
by dws (Chancellor) on Jan 12, 2003 at 17:51 UTC
    Why not write a quick CGI script to display a template?

    This is as much a human issue as it is a technical one.

    The designers I'm dealing with are not developers. Setting things up so that they can open a template directly in a browser is easy for them. Easy in this case is Good. Requiring that they copy the template onto a web server, then pull up a form and name the template, adds nuisance work to their plates. Nuisance in this case is Bad.

    If I was working with development-savvy page designers, a CGI to pre-process the template mght be an option.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://226231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found