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).

So, I took the main engine of this site, and refined a few parts of it, adding useful, explicatory comments so 5 years from now I won’t have to again go “how on earth does this work again?”

I enjoyed the brainteaser of retracing my steps from the past, puzzling through a few knotty bits of parsing and using the experience I have gained since to better traverse arrays and clean up the code in a lot of tiny ways.

I love improving the hidden bits, making them better in ways that no one but me sees. Gives me great satisfaction. Unsurprisingly, that’s the part I like about dentistry, too. The patient neither knows nor cares about the precision of the fit of their crown, but I do, and I want it to be not just good enough, but remarkable.

Brief Notes Nearby