Re: [htmltmpl] extra whitespace
Brought to you by:
samtregar
From: Mark A. F. <mar...@ea...> - 2006-02-08 22:11:29
|
From: Alex Teslik <al...@ac...> >Is there a switch (feature request?) that will tell HTMLTMPL to replace a >TMPL followed by [\n\r]+ with nothing - even better replace the whole line= if >the only thing on the line is a TMPL tag?=20 I raised this issue a year or two ago and it wasn't well-received. It seems= like it's common for newcomers (as I was) to spot this and believe it's a = shortcoming in H::T. Among experienced users, they believe it's easier and = faster to use the "filter" option to strip *all* linefeeds if wasted bandwi= dth is your motivation to remove some. If the performance overhead of using= the "filter" option is a concern, then preprocess your templates to load, = filter and output them to another file which will be your template to be us= ed at run-time.=20 I do this for other reasons, like if there is common processing to be appli= ed to parts of the page once. For example: international language substitut= ion of headings, labels, etc. I use tags prefixed as "PREPROC-" in my *mast= er* template to differentiate things that need to be preprocessed versus th= e tags that are dynamically set at run time. I use a batch script to load t= he template and "filter" the TMPL- tags to "HOLD-" tags, change the "PREPRO= C-" tags to "TMPL-" tags. I don't strip the linefeeds in this filter. I do = my preprocessing to set TMPL-VARS and LOOPS as necessary for one-time initi= alization of the page (for example, language substitution). I output the H:= :T object to a variable and perform a regex on the variable to change all t= he "HOLD-" tags to "TMPL-" tags. This is where I strip the linefeeds. Then = print this variable to a file which will be the template used at runtime. S= o, I have a master template (with includes, etc.) and a run-time template t= hat needs no run-time processing except the actual variables that can chang= e at run time (messages, dynamically generated lists, etc.). That's probably a much more complicated example than what you need just to = strip linefeeds. The filter option will work for you. I just wanted to demo= nstrate that there's a lot of ways to solve a problem with H::T if you real= ize you're not stuck with just one preconceived way to use it. It took me a= while to get that through my head. In the end I agreed that it's superior t= o use features like I described above than to burden H::T with indicators a= bout what is essentially formatting (retention or removal). Hope that helps. Mark |