Sun, 24 Aug 2003

top

interpolate_pseudoxml

<<reverse < index > forward>>

I don't know why, but I felt like mucking around with interpolate plugins for blosxom, and basically hacked at Rael Dornfest's interpolate_fancy. Most of it is cosmetic, granted. I didn't like how variables had to be written as <$variable />, especially when in the attributes of tags (e.g. things like <a href="<$path />"> gave me serious heebie-jeebies), but I thought that putting some sort of delimiter (in my case, I chose braces) would be useful so that variables could abut text (like this: {$verb}ing), which was not possible with the default routine.

I also changed the pseudo-markup to something that I felt more comfortable with. I don't know why. The <?></?> tag pairs didn't cut it for me. I wanted something that was, well, more jarringly visible. So now you have three needlessly verbose tags: <blosxom:if-exists>, <blosxom:if-not-exists>, and <blosxom:test>. Like I said, purely cosmetic, since they do the same things that the original tags did. I had originally wanted to mimick XSLT syntax since I had grown accustomed to and perhaps fond of it, but I had serious problems coming up with the regexes, so I gave up.

The one thing that might have some utility to it is the fact that I hacked in the /s modifier onto the substitutions, allowing you to have conditionals that span more than one line. Very useful with creating writeback flavours that are derived from the html flavour without having to strip newlines and making the markup unreadable (see below to see how I use one flavour to create both the html and writeback flavours.) Unfortunately, using /s makes the interpolate routine incredibly slow. Sadly, I have no idea how to make things more efficient, but I have no intention of cramming all my conditional markup onto a single line. Perhaps I will have to resort to generating component flavours from a combined format flavour file. (I haven't used Geoffrey Alexander's Flavourizer yet. Something tells me that I'm going to end up writing my own script to do it the hard way.)

You can check out my interpolate_pseudoxml plugin, but I'm not going to submit it or anything because it is unbearably slow, and I made up my own markup for no real good reason.

But as for writeback flavours, since I got sick of editing two files each time I wanted to make a change, what I did was create my head, date, story, and foot components for the html flavour, and then I symlinked them as their corresponding writeback components. For example, ln -s head.html head.writeback. Then in each component file, where necessary (probably most importantly in the story component and maybe the foot component), I used conditionals to add in the necessary markup depending on whether the html flavour or the writeback flavour was being requested.

Examples:

interpolate_conditional syntax: {$flavour=writeback [additional markup for writebacks]}
interpolate_fancy syntax: <?$flavour eq="writeback"> [additional markup for writebacks]</?>
interpolate_pseudoxml syntax: <blosxom:test var="$flavour" eq="writeback"> [additional markup for writebacks]</blosxom:test>

If you want, you can look at the flavour components used to generate this page:
head.html
date.html
story.html
foot.html

08:26:33 24 Aug 2003 > /computers/www/blosxom > permalink > 0 comments

comments

Comment form

Name:
URL/Email:
[http://... or mailto:you@w...] (optional)
Title:
(optional)
Comments:
Save my Name and URL/Email for next time
To prevent comment spam, please retype the characters in this image
Enter the text here: