Go to content Go to blog navigation Go to link heaven

Templation

Recent Updates

Recent Articles

Search

RSS feed Atom feed

Meta Data Semantics

2005.10.07 19:03

Meta tags are the switches that control Templation. The values you put in your meta tags become the all-important meta data in the system. Usually this transformation is straightforward; but there are a few special cases to be aware of.

True and False

The string 'false' actually evaluates to true in PHP, so the first thing that happens to meta tags with the strings 'true' or 'false' is that they get converted into their respective boolean values. This means it's currently impossible to actually get a meta value containing the string representation. While that could conceivably cause some confusion, its much better than wondering why if(!$meta_key) doesn't get executed when the meta tag clearly says false.

Integers

Any meta tag containing only digits will be converted to its respective integer value. In PHP integer strings tend to be coerced to integers anyway, but I figured this was just good practice. At least is_int() will return true.

Lists

In beta 2 automatic list parsing was added. Meta tags containing commas would be split up into arrays automatically. Before that, each widget had to parse its own lists. Well, automatic list parsing turned out to be not such a bright idea. It complicates things to very little advantage. So the list parser has now been added as a function:

Templation_Widget::metaToArray($string[, $trim]) 

That function takes in a meta value (usually a string) and spits out an array containing the value split on unescaped commas. It always returns an array, however, even if the array contains only a single value.

I haven't given up on automatic list parsing entirely, but its clear that it should not be allowed to pollute the simplicity of the meta data system. Beta 3 will be released soon resolving this and many other issues.

Other Issues

The other issue to be aware of is that a meta value can in no way have a double quote in it. Any other character you can get away with inside a meta tag, although < and > are probably pretty dicey too. You can encode these characters, but meta values are never unencoded unless a widget were to explicitly do so. Despite the feasability of such things, meta data aren't really meant for content as such. Better to put anything longer than half a sentence in an include either directly or using some clever widget.

Comments