[Templates] Apache::Template 0.09 (was: changing content type)

[prev] [thread] [next] [Date index for 2004/04/27]

From: Andy Wardley
Subject: [Templates] Apache::Template 0.09 (was: changing content type)
Date: 09:36 on 27 Apr 2004
Randal L. Schwartz wrote:
> I had a similar problem... so I created this:

[...snipola...]

> Note the comment... Apache::Template isn't pluggable enough, so I had
> to cut-n-paste (evil) the entire headers method just to disable the setting
> of content-type. :)

Version 0.09 of Apache::Template is now on its way to CPAN.  Available
right here, right now:

  http://wardley.org/perl/Apache-Template-0.09.tar.gz

This adds 'type' to the TT2Headers options:

  TT2Headers    type length etag

Note that if you don't specify any TT2Headers option then you get
just 'type' by default (same as 0.08 and before).  But if you are 
currently using TT2Headers then you will now need to explicitly add
'type' if you want the Content-Type sent (or leave it out if you don't).

  TT2Headers    length etag          # v0.08 and earlier - 'type' implicit
  TT2Headers    type length etag     # v0.09 - must add 'type' explicitly

Or you can set it to 'none' and, unsurprisingly, you get none of the 
headers.

  TT2Headers   none

There is also the TT2ContentType option to set a different Content-Type
to the default of 'text/html'.

  TT2ContentType  text/xml

> But now, from within my template code, I can say things like:
> 
>         [%
>                 IF content_type() == "text/html";
>                 ...
>                 END;
>         %]

I didn't add anything to do this explicitly because you can currently make 
the request accessible and do it through that:

  TT2Params    request

And then in the template:

  [% IF request.content_type == 'text/html';
       ...
     END
  %]

Not quite as succinct, but it does the job and saves us from having to 
having to add anything to Apache::Template that can't easily be added
in a subclass.

Thanks for the code and ideas!

Cheers
A


_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

[Templates] CHanging content type under Apache::Template.
=?ISO-8859-1?Q?Lo=EFc?= Paillotin 13:09 on 26 Apr 2004

Re: [Templates] CHanging content type under Apache::Template.
=?ISO-8859-1?Q?Lo=EFc?= Paillotin 13:47 on 26 Apr 2004

Re: [Templates] CHanging content type under Apache::Template.
=?ISO-8859-1?Q?Lo=EFc?= Paillotin 07:52 on 27 Apr 2004

Re: [Templates] CHanging content type under Apache::Template.
merlyn (Randal L. Schwartz) 15:22 on 26 Apr 2004

[Templates] Apache::Template 0.09 (was: changing content type)
Andy Wardley 09:36 on 27 Apr 2004

[Templates] Re: Apache::Template 0.09 (was: changing content type)
merlyn (Randal L. Schwartz) 13:32 on 27 Apr 2004

Re: [Templates] Apache::Template 0.09
Geoffrey Young 21:38 on 27 Apr 2004

Re: [Templates] Apache::Template 0.09
merlyn (Randal L. Schwartz) 21:50 on 27 Apr 2004

Re: [Templates] Apache::Template 0.09
Geoffrey Young 22:07 on 27 Apr 2004

Generated at 08:56 on 15 Mar 2005 by mariachi v0.52