Re: [htmltmpl] H::T chunking of templates
Brought to you by:
samtregar
From: Pete P. <pet...@cy...> - 2004-03-08 16:40:05
|
Mathew Robertson wrote: >>>I was looking through H::T when I noticed that it splits the incoming template using: >>> >>> split ( /(?<=)/ , $template) >>> >>>This regex ends up splitting on every '<'. >>> >>>I have modified my version to use: >>> >>> split( m!(?=<(?:\!--\s*)?/?[Tt][Mm][Pp][Ll]_)! , $template) >>> >>>which thus matches only on <TMPL_ and </TMPL_ tags. >>> >> >>Won't this break if you use the <!-- TMPL... --> constructs of putting >>the TMPL tags within HTML comments? > > > Not from my testing it didn't; this regex only matches on: > > <TMPL_ > </TMPL_ > <!-- TMPL_ > <!-- /TMPL_ > > doesn't matter where the TMPL_ construct is located. > > However you could be right as there may be some cases where the regex doesn't quite match correctly, although I cant think of such a situation. Ah, now I see. I read the text you wrote instead of the regex because, you know, I'm not a regex engine. ;) Of course *had* I properly read the regex you wrote, I would have figured it out. Couldn't you use a case-insensitive match though to avoid the [Tt][Mm][Pp][Ll] part? Pete |