Re: jinja2 as renderer
will kahn-greene <[email protected]> Wed, 24 Feb 2010 09:19:07 -0500
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
I think this is awesome and (weirdly) had a dream about writing a jinja2 renderer last night. Seriously. Really weird. It'd be good to support the blosxom renderer callbacks in the jinja2 renderer because then it's more likely plugins will "just work". Otherwise, you (or someone else) will have to create jinja2 versions of plugins. Definitely worth looking into some more. jinja2 (or any templating engine, really) would solve a ton of problems we have with the blosxom renderer and would probably make templating easier. I just wish we didn't have to go re-write a lot of stuff to switch to it. I don't have time to look into it more this week (slurping PyCon video, pushing out Miro 3.0, writing a User Manual for Miro 3.0, ...), but I've got it in my list of things to do soon. On 02/24/2010 08:26 AM, Sebastian Spaeth wrote: > Hi all, > > as I wanted to learn more about the pyblosxom architecture, I coded a > Renderer plugin that uses jinja2 as a renderer. jinja2 is an excellent > templating system that gives you lots of functionality and closely > resembles the style in django web apps. > > I put it up here: http://bitbucket.org/spaetz/pyblosxom_blog/ > You can clone it with hg clone > https://spaetz-HWgY0/vhk/[email protected]/spaetz/pyblosxom_blog/ > (it contains all my private blog posts, sorry for that :)) > > All the changes are in 6 commits from > 5abac1380cd7 .. 5eea5ffa0b60 > Most of them are amazingly trivial. > > It can be turned on by just loading it as a plugin and setting > py['renderer']='jinja2' in your config.py (of course you need to have > jinja2 installed). And you also need the corresponding template files in > <datadir>/flavours/jinja/<flavor>.flav. In one of the above commits I > add template files for atom, rss20, snarfed (html based on snarfed but > heavily modified). > > What breaks: > - I had problems with non-ascii chars in filenames, using > python2.5. UTF-8 in posts works fine though. > - I am a bit unsure which callback will break when you switch away from > the blosxom renderer though. The cb_story one will break for sure (I > added a cb_jinja2 one though that plugins can use). > - I don't have beautiful documentation written for it. > > Why do I like it? > - I like the templating language. It is powerful and easy to understand > - One template for stories that inherits from base templates, rather > than concatenating lots of individual templates. > For example, this let me set set the 'title' in<head> in a story > view. Usually the story title is only available in the story > template at which time it is too late to manipulate<head>. > - It was amazingly simple to plug in a new Renderer. > - I learned a lot while coding it :) > > > If you find it useful, have fun. Otherwise sorry for the noise. > > Sebastian > > P.S. You can see it in action at http://sspaeth.de/ (some German, some > English posts). > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Pyblosxom-devel mailing list > Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev