Yeah good point -- I actually just updated it for Python and
JavaScript a few days ago. I will update it and write something, but
for now the best examples are in the tests.
http://code.google.com/p/json-template/source/browse/jsontemplate_test.py
(search for PredicatesTest)
The gist is:
Predicates allow you to conditionally include a portion of the
template. They have access to the current value/node as well as the
"current context". Unlike "sections", they don't change the context
for variable lookup.
1. In terms of the API, predicates can be registered like formatters,
either through a simple dictionary or through the various *Registry
classes, like PrefixRegistry
2. In terms of the template syntax, it is simple {.if} {.or}
{.if singular}
One
{.or plural}
More than one
{.or}
None
{.end}
"singular" and "plural" are the names that are registered with the
Template when it's constructed.
There are a few built-in predicates. A very common one is "test",
which will test for an attribute:
{.if test debug}
Some debug text
{.end}
That is, if you have {"debug": true} in your JSON, this will be shown.
There is also a shortcut for "test" that lets you use ? --
{.debug?}
Some debug text
{.end}
That is identical to the above. Hope that helps.
Andy