
Template::plugin::cycle is a small, simple, and hopefully dwim solution to these sorts of tasks.
it can be used either as a normal template::plugin, or can be created directly and passed in as a template argument, so that you can set up situations where it is implicitly available in every page.