https://www.icyphoenix.com/viewtopic.php?f=35&t=8466
-----------------------------------
jhl
Fri 06 Apr, 2012 00:38

Ways To Improve Templating
-----------------------------------
These comments refer to the 2.0 beta release. While critical observations, I hope they will be accepted positively.

Having spent three (!) days on the album templates, there seems to be so much repetitive code. The most evident example is the thumbnail image. It appears in an album or album category (once for each column in each row), in recent pictures, in highest rated pictures, most viewed, and random. I hope that's the full list.

Yet it should only be templated once, IMHO. Unfortunately this is not currently possible. I've done some experimenting, by adding an ALIAS keyword to the template engine, which works - to a point.

It works because I can alias personal_picrow.pic_detail, recent_pics_block.recent_pics.recent_detail, highest_pics_block.highest_pics.highest_detail, mostviewed_pics_block.mostviewed_pics.mostviewed_detail, random_pics_block.rand_pics.rand_detail to a single variable, say detail.

(Note in those examples only the first part of the namespace needed to be unique, the others could all be pics.detail for example.)

To a point, because the back end code is equally repetitive, and not identical. There is a great need for a naming convention here. While most back end code produces keys such as POSTER, TIME, VIEW and RATING, for some reason highest_pics_block.highest_pics.highest_detail and mostviewed_pics_block.mostviewed_pics.mostviewed_detail use an H_ prefix for these variables, thus defeating the single template approach.

At this point I think I will simple correct these two generators, and push the corrections to the main GIT repository, but of course, I will also have to correct the existing templates. The inertia here is tremendous, and the risk is, that without a great deal of house cleaning (though I appreciate that much has already been done in this new release) things will continue to degrade.

I've read the coding convention HTML page, but a naming convention page is also needed, again IMHO.

If this appears to be a rant, well, it's been a long week. Happy Easter all,

John


