Attachment 'jtemplate.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 
   3 import sys
   4 from jinja2 import Environment, FileSystemLoader
   5 from MoinMoin import config
   6 
   7 Dependencies = ['user']
   8 
   9 class Parser():
  10 
  11     extensions = '*'
  12     Dependencies = []
  13 
  14     def __init__(self, raw, request, **kw):
  15         self.raw = raw
  16         self.request = request
  17         self.env = Environment(loader=FileSystemLoader(self.request.cfg.jinja2_templates, encoding='utf-8'))
  18         self.template_name = kw.get('format_args', '').strip()
  19 
  20     def format(self, formatter):
  21         template = self.env.get_template(self.template_name)
  22         params = {}
  23         self.lines = self.raw.expandtabs().split('\n')
  24         for line in self.lines:
  25             (name, value) = [x.strip() for x in line.split(':', 1)]
  26             params[name] = value
  27         self.request.write(formatter.rawHTML(template.render(params)))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-01-08 20:16:29, 0.8 KB) [[attachment:jtemplate.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.