Blog Archive for May 18, 2010

Django Templates

May 18, 2010

To render a django template in your code, simply import the render_to_string function, pass it a template and a context, and it will return you back the template rendered with that context.

from django.template.loader import render_to_string

lRenderedString = render_to_string('template.htm', {'Class' : lClass})

Google diff match patch tools

May 18, 2010

This google code library can be used to produce rich diffs of text, complete with strikeout and colour highlighting. It has language support for c++, csharp, javascript, python, lua and java.

Diff

To produce a nice HTML diff, use this code:

from diff_match_patch import diff_match_patch

lDiffClass = diff_match_patch()
lDiffs …