Theme XML format

One of the main challenges I placed on myself in building the new theme engine for the repository, was that theme administrators shouldn't have to know anything about WebObjects or the code of the repository in order to design and implement their theme(s).

The other main challenge was to make it as simple as possible for the theme administrators, including the ability to use whatever editor they feel comfortable with.

To address these two needs, I had to think long and hard about the way WebObjects handles pages and templating, with the separate .html and .wod files that beautifully enforce the Model-View-Controller pattern. To do this properly would require turning my back on MVC in this instance. Is that such a bad thing?

I looked at many of the components in CAREO, as well as the Learning Commons website, and realized that MVC wasn't really being used. Sure, the bindings for a component were separate from the html itself, but so what? It was basically just a denormalized version of an html page with dynamic bindings - the .wod file was really just in the way.

With the assumption that I could go ahead with a single-file-to-edit strategy, I created a simple xml element that would be used to represent WebObjects components in a templated page: ucwebobject. Creative, no?

ucwebobject has only 1 required attribute: classname. classname is the name of the WebObjects class used to represent the component (like, say, WOString, WOTextField, WOImage...). Any other attributes for ucwebobject are mapped into the bindings used by that component (a WOString might have a "value" attribute, etc...).

Here's a sample ucwebobject for a localized string:

Note that value of the "value" attribute begins with a $. That marks it as a literal string, and it will be wrapped in quotes when fed into WebObjects for rendering. Any attribute value not having the $ will be assumed to be a class variable, and will not have quotes so that WebObjects will grab the appropriate "live" bit of data.

Here's another one that has dynamic bindings:

This one pulls the variable "firstName" from the session objects' user variable (in this case, an EO).

Also, since the source fragments are now XML, all attributes MUST be in quotes in the source, and all elements MUST be balanced and closed properly, or the transformation into .wod and .html will fail.

comments powered by Disqus