Templates and customization
Jeremy Bowers <[email protected]> Fri, 12 Mar 2004 11:25:23 -0500
| Newsgroups | gmane.comp.pythin.pyds.devel |
|---|---|
| Message-ID | <[email protected]> |
I've been customizing my templates lately, and I've been finding it a challenge. I don't mean to sound arrogant, but if I'm finding it a challenge many others will find it impossible. Specifically, I just added code to the weblog entry form to render the categories in columns, because I have 50 categories. (Many of these are vestigial, created over the course of the last three years, but they still exist.) This added Yet More Complication to the templates, and if anybody in the future wants to modify this code, it's one more thing they'll have to worry about in every template. As a result I'm hesistant to submit the patch. I'm thinking that "ideally", we want to pull things like the category listing into Python code, so that a template author just writes $categoryEntry() or something, and the code takes care of columns and such. The problem is, the complication in the templates is, for lack of a better word, "real"; the templates are implementing real features and sometimes they are the best way to implement the features. I find it hard to articulate but if you read the templates over with an eye towards what what could be pulled into the Python code I think you'll see what I mean. The pattern seems to be something like #if complicateBooleanDeterminingIfFeatureIsRelevant <some potentially complicated HTML code> #else <some potentially complicated other HTML code> #end if and a theme may want to change either of those two HTML segments to "fit", so you can't suck those into Python code without loss of the ability to customize. So, topic of conversation: Is it worth trying to simplify the .tmpl code, or is the flexibility too important to give up? I'm willing to start migrating code to macros over time as I make changes (starting with moving the category printing code into a macro as a proof-of-concept), but only if it's worth it. And I'm not sure either way.