PATCH ( was Re: [Petal] stripping whitespace in templates? )

Jonathan Vanasco petal-list at 2xlp.com
Tue Oct 17 00:22:45 BST 2006


attached is a patch ( + the patched petal, in case others have issues  
reading it )

it adds a strip_whitespace argument to new + a function + documentation

it runs a quick boolean check in the sub '_file_data_ref' , which  
just wraps HTML::Strip::Whitespace

templates are quite smaller...

    on 1 webapp
	w/ strip_whitespace:   	749,416
	wo/strip_whitespace:	802, 395

     so its about a 6.65 % size reduction in a webapp.  its only  
50k , but under modperl that can be 1MB easily when you're running  
multiple servers

-------------- next part --------------
102,105d101
< # strip whitespace mode
< our $STRIP_WHITESPACE = 0;
< 
< 
149d144
<     local $Petal::STRIP_WHITESPACE = 0;
165d159
<     local $Petal::STRIP_WHITESPACE = 0;
179d172
<     local $Petal::STRIP_WHITESPACE = 0;
259d251
< sub strip_whitespace   { exists $_[0]->{strip_whitespace}   ? $_[0]->{strip_whitespace}   : $STRIP_WHITESPACE   }
361d352
<     local $STRIP_WHITESPACE   = defined $self->{strip_whitespace}    ? $self->{strip_whitespace}    : $STRIP_WHITESPACE;
617,629c608,609
< 
<     local $STRIP_WHITESPACE   = defined $self->{strip_whitespace}    ? $self->{strip_whitespace}    : $STRIP_WHITESPACE;
<     if ( $STRIP_WHITESPACE )
<     {
<          use HTML::Strip::Whitespace qw(html_strip_whitespace);
<          my  $res_stripped= '';
<          html_strip_whitespace( 'source'=> \$res , 'out'=> \$res_stripped );
<          $res = $decode->process ($res_stripped);
<     }
<     else 
<     {
<          $res = $decode->process ($res);
<     }
---
>     
>     $res = $decode->process ($res);    
1005,1012d984
< =head2 strip_whitespace => I<true> | I<false> (default: I<false>)
< 
< If set to C<true>, Petal will utilize HTML::Strip::Whitespace to remove 
< whitespace from template documents, before parsing them into a canonical 
< template.  This can result in smaller templates and better memory use in shared 
< environments like mod_perl.
< 
< 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Petal.pm
Type: text/x-perl-script
Size: 49594 bytes
Desc: not available
Url : https://lists.webarch.co.uk/pipermail/petal/attachments/20061016/e1a18446/Petal.bin
-------------- next part --------------



More information about the Petal mailing list