Edgewall Software

Changes between Version 3 and Version 4 of GenshiRecipes/WerkzeugWithGenshi


Ignore:
Timestamp:
Jul 23, 2008, 12:23:11 PM (16 years ago)
Author:
jruigrok
Comment:

Pass data as a keyword dict.

Legend:

Unmodified
Added
Removed
Modified
  • GenshiRecipes/WerkzeugWithGenshi

    v3 v4  
    55== Templated Response class ==
    66
    7 This class cuts back on the standard calls to load the template, generate a stream and populate it with data and subsequently render it. The data parameter is best passed as a dict.
     7This class cuts back on the standard calls to load the template, generate a stream and populate it with data and subsequently render it. The data parameter is passed as a dict.
    88
    99{{{
     
    3030            TemplatedResponse.loader = TemplateLoader(TEMPLATES_DIR, auto_reload=True)
    3131        self.template = self.loader.load(template)
    32         self.stream = self.template.generate(data=data)
     32        self.stream = self.template.generate(**data)
    3333        response = self.stream.render('xhtml', doctype=DocType.XHTML_STRICT)
    3434        Response.__init__(self, response)
     
    4141return TemplatedResponse(template='my_template.html', data={'name': some_variable})
    4242}}}
     43
     44and in the template itself you will use `name` with a simple `${name}` call.