>>>>> "Bart" == Bart Schuller <[EMAIL PROTECTED]> writes:
Bart> Hello,
Bart> I bumped into a small limitation in A::T in that the content-type is
Bart> hardwired to always be text/html. So my browsers have been quite
Bart> forgiving with my templated CSS file. But now that I needed a Java
Bart> Webstart file templatized, the problem had to be solved. It shouldn't
Bart> take more than a few minutes, and it didn't.
Wow... that's a lot simpler than my solution. I added a coderef
that gets and sets content-type:
package Stonehenge::Template::Service::Apache;
use base qw(Template::Service::Apache);
sub params {
## use Stonehenge::Reload; goto ¶ms if Stonehenge::Reload->reload_me;
my $self = shift;
my $params = $self->SUPER::params(@_);
$params->{content_type} = sub {
## warn "Calling content_type with @_";
Apache->request->content_type(@_);
};
return $params;
}
## I hate cut-n-paste
sub headers {
my ($self, $r, $template, $content) = @_;
my $headers = $self->{ SERVICE_HEADERS };
my $all = $headers->{ all };
## just to comment this out ## $r->content_type('text/html');
## warn "content type when sending headers is ", $r->content_type();
$r->headers_out->add('Last-Modified' => ht_time($template->modtime()))
if $all or $headers->{ modified } and $template;
$r->headers_out->add('Content-Length' => length $$content)
if $all or $headers->{ length };
$r->headers_out->add('E-tag' => sprintf q{"%s"}, md5_hex($$content))
if $all or $headers->{ etag };
$r->send_http_header;
}
1;
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates