I'll just weigh in here on my thoughts about Cheetah, mainly that I think it is bad to allow much logic in the template code. Agreed that we all need conditionals, but seeing 'getVar' in there really throws some flags for me.
The other benefits are that the engine is a single file and easily extensible with formatters
The "json" part of it comes from the fact that it was designed and implemented in python and javascript at the same time.
There are a variety of style nits (extra spaces before or around things, importing objects instead of modules, using tabs instead of spaces in the xml), so please take another scan over the code to resolve those :)
Other than those discussion points looks like a great addition to our core functionality :)
I'll just weigh in here on my thoughts about Cheetah, mainly that I think it is bad to allow much logic in the template code. Agreed that we all need conditionals, but seeing 'getVar' in there really throws some flags for me.
A much much smaller but powerful and declarative-style templating engine that I've grown to prefer is called jsontemplate, http:// json-template. googlecode. com/svn/ trunk/doc/ Introducing- JSON-Template. html
Our usage is pretty minimal here so the syntax isn't shockingly different but in Cheetah
#if $getVar('kernel', None)
<kernel> ${kernel} </kernel>
<initrd> ${ramdisk} </initrd>
<cmdline> root=/dev/ vda1 console= ttyS0</ cmdline>
#if $getVar('ramdisk', None)
#end if
#end if
and
template_contents = open(FLAGS. libvirt_ xml_template) .read() template_ contents, searchList=[ xml_info ] ))
str(Template(
becomes
{.section kernel}
<kernel> {kernel} </kernel>
<initrd> {ramdisk} </initrd>
<cmdline> root=/dev/ vda1 console= ttyS0</ cmdline>
{.section ramdisk}
{.end}
{.end}
and
jsontemplate. FromFile( FLAGS.libvirt_ xml_template) .expand( xml_info)
The other benefits are that the engine is a single file and easily extensible with formatters
The "json" part of it comes from the fact that it was designed and implemented in python and javascript at the same time.
There are a variety of style nits (extra spaces before or around things, importing objects instead of modules, using tabs instead of spaces in the xml), so please take another scan over the code to resolve those :)
Other than those discussion points looks like a great addition to our core functionality :)