I'm still at a loss why a simple filter function couldn't do this work.

Perhaps what we need is people to contribute filter functions to do these
kinds of things.  

Brian

-----Original Message-----
From: Jody Biggs [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, February 11, 2003 3:19 PM
To: simran; Jay 'Whip' Grizzard
Cc: [EMAIL PROTECTED]
Subject: Re: [htmltmpl] Trimming whitespace


hear hear!

I've got some _extremely_ ugly templates that are outputting CSV or tab
delimited data, as they loop through data cells in each row, and have
several conditions within each row and cell...

perhaps it would be reasonable to consider adding an option for stripping
white space out of lines which contain nothing but an HTML::Template tag?

 - j

--- simran <[EMAIL PROTECTED]> wrote:
> On Tue, 2003-02-11 at 05:27, Jay 'Whip' Grizzard wrote:
> > On Fri, Feb 07, 2003 at 12:54:59PM -0500, Sam Tregar wrote:
> > > On Fri, 7 Feb 2003, Drew Taylor wrote:
> > > 
> > > > Is there a way to trim the extra whitespace\newlines from the
> final output?
> > > > I didn't notice anything in the docs so I thought I'd ask here.
> > > 
> > > HTML::Clean works for some people.  In general I don't let it
> bother me.
> > > It's just a few extra bytes and the browser certainly doesn't
> care.
> > 
> > Problem is, sometimes the browser -does- care. There's not a
> difference
> > between "one character of whitespace" and "many characters of
> whitespace", but
> > there is a difference between those and "zero characters of
> whitespace".
> 
> Agree. Also, HTML::Template is i think used in quite a wide range of 
> applications - and its not uncommon (at least at my workplace) to 
> encounter this templating mechanism to produce output for other 
> applications (eg, XML, CSV, TXT, ...) and sometimes those applications
> do care about the number of whitespaces.
> 
> >  
> > 
> > Me personally, I use an HTML::Template::Extension module to do it.
> Heck,
> > said module even appears to be appended to this email. Usage: use
> PACKTAGS
> > as an extension, and close some of your tags with " #>" (note the
> space)
> > instead of >. Any tags closed that way will cut off output until
> the next
> > tag in the template. (This could be trivially adjusted to just
> remove
> > whitespace, as well .. adjust _pack_tags in the obvious way).
> > 
> > Incidentally, this script solves one of the two complaints I've had
> about
> > HTML::Template. The other complaint? There isn't a way to
> incrementally
> > render loops, since you have to give it the entire contents of the
> loop at
> > once. It seems silly to hold several thousand iterations of data in
> memory,
> > when one could just output an iteration at a time...
> > 
> > Anyhoo. Enjoy.
> > 
> > -jay
> > 
> >                            ----- CUT HERE -----
> > 
> > 
> > package HTML::Template::Extension::PACKTAGS;
> > 
> > $VERSION            = "0.01";
> > sub Version         { $VERSION; }
> > 
> > use Carp;
> > use strict;
> > 
> > my $classname;
> > my $parentname;
> > 
> > 
> > my %fields  =
> > (
> >  ecp_compatibility_mode => 0,
> > );
> >      
> > 
> > my @fields_req  = qw//;
> > 
> > 
> > sub new
> > {
> >     $classname = shift;
> >     my $self = shift;
> >     $parentname = ref($self);
> >     bless $self,$classname;
> > 
> >     $self->_init_local(@_);
> >     return $self;
> > }
> > 
> > 
> > sub _init_local {
> >     my $self = shift;
> >     my (%options) = @_;
> > 
> >     # Assign default options
> >     while (my ($key,$value) = each(%fields)) {
> >         $self->{$key} = $self->{$key} || $value;
> >     }
> > 
> >     # Assign options
> >     while (my ($key,$value) = each(%options)) {
> >         $self->{$key} = $value
> >     }
> > 
> >     # Check required params
> >     foreach (@fields_req) {
> >         croak "You must declare '$_' in " . ref($self) . "::new"
> >         if (!defined $self->{$_});
> >     }
> > 
> >     $self->push_filter();
> > }
> > 
> > 
> > sub push_filter {
> >     my $self = shift;
> >     bless($self, $classname);
> > 
> >     push(@{$self->{filter}}, @{$self->_get_filter()});
> >     bless($self, $parentname);
> > }
> > 
> > 
> > sub _get_filter {
> >     my $self = shift;
> >     my @ret ;
> > 
> >     # Sorry for this :->. I've an e-commerce project called ecp
> that
> >     # use a CSTART modified syntax using html comment
> >     push @ret,\&_pack_tags if ($self->{ecp_compatibility_mode});
> > 
> >     # Standard CSTART syntax
> >     push @ret,\&_pack_tags;
> > 
> >     return \@ret;
> > }
> > 
> > 
> > sub _pack_tags {
> >     my $template = shift;
> > 
> > #    $template = $$template;
> > #    print STDERR $template;
> > 
> >     $$template =~ s/\s+#>[^<]*</></g;
> > 
> >     return $template;
> > }
> > 
> > 1;
> > 
> > 
> > -------------------------------------------------------
> > This SF.NET email is sponsored by:
> > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2
> See!
> > http://www.vasoftware.com 
> > _______________________________________________
> > Html-template-users mailing list 
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/html-template-users
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! 
> http://www.vasoftware.com 
> _______________________________________________
> Html-template-users mailing list 
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users


__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com _______________________________________________
Html-template-users mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated 
recipient(s) named above.  If you are not the intended recipient of this message you 
are hereby notified that any review, dissemination, distribution or copying of this 
message is strictly prohibited.  This communication is for information purposes only 
and should not be regarded as an offer to sell or as a solicitation of an offer to buy 
any financial product, an official confirmation of any transaction, or as an official 
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or 
error-free.  Therefore, we do not represent that this information is complete or 
accurate and it should not be relied upon as such.  All information is subject to 
change without notice.




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to