1 # Create your views here.
3 from django.http import HttpResponse
4 from librarian import html
6 from StringIO import StringIO
9 LINE_SWAP_EXPR = re.compile(r'/\s', re.MULTILINE | re.UNICODE);
12 style_filename = html.get_stylesheet('partial')
14 data = request.POST['fragment']
15 path = request.POST['part']
17 base, me = path.rsplit('/', 1)
18 match = re.match(r'([^\[]+)\[(\d+)\]', me)
19 tag, pos = match.groups()
21 print "Redner:", path, base, tag, pos
23 style = etree.parse(style_filename)
25 data = LINE_SWAP_EXPR.sub(u'<br />\n', data)
26 doc = etree.parse( StringIO(data) )
29 'with-paths': 'boolean(1)',
30 'base-path': "'%s'" % base,
36 result = doc.xslt(style, **opts)
41 etree.tostring(result, encoding=unicode, pretty_print=True) )