Jonathan Vanasco | 8 Oct 02:25

stripping whitespace in templates?


does anyone have a suggestion as to how i could create a plugin/ 
filter that would strip certain kinds of whitespace during the  
template generation phase?

my templates all have a fair amount of spaces / tabs / carriage  
returns to make templates human readable

it also bulks stuff up about 15% ( i haven't tested the space  
difference using gzip compression, or any difference in speed  
gzipping a stripped document vs a nonstripped )

it seems to me though, that i could probably cut bandwidth by 7% or  
so if i regexed my templates, so i'd like to look into it

anyone have a clue where i could insert the function?  within petal?   
within mkdoc ? 

Jonathan Vanasco | 17 Oct 01:22

PATCH ( was Re: stripping whitespace in templates? )

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

102,105d101
< # strip whitespace mode
< our $STRIP_WHITESPACE = 0;
< 
< 
149d144
<     local $Petal::STRIP_WHITESPACE = 0;
165d159
<     local $Petal::STRIP_WHITESPACE = 0;
179d172
(Continue reading)


Gmane