tumbledry

regularexpressions

You are viewing stuff tagged with regularexpressions.

Content and Presentation

I just finished revisiting some regex code that begins like this:

preg_match_all('%{\$([^} ]+?)}%u', $template, $templateTags);

and becomes a rather bit more complex after that. I wrote it back in 2008. That aging code was sound but needed some updating; actually, I remember walking through Saint Paul, on my way to workout at St. Thomas (at a gym that no longer exists), puzzling through the right way to do nested parsing of template code. I wanted to be able to write these nice clean templates that this chunk of code would then take a look at and replace with content. What I mean is, if you can keep content apart from presentation, you are afforded a lot of flexibility. So, if in the future webpages are written in a completely different language, or if I want to produce an archival version of the site (say, a printed book) in a different format, then this code is the bridge between raw information (content) and final output (presentation).

Continued