Changes between Initial Version and Version 1 of MyghtyTemplatesInDjango


Ignore:
Timestamp:
Aug 2, 2006, 6:03:15 AM (18 years ago)
Author:
riklaunim@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MyghtyTemplatesInDjango

    v1 v1  
     1Using Myghty templates in Django is easy.
     2
     31. Install Myghty - [http://www.myghty.org/ Myghty.org]
     4
     52. edit yours views like this:
     6
     7{{{
     8import myghty.interp as interp
     9from django.http import HttpResponse
     10
     11interpreter = interp.Interpreter(
     12        data_dir = '/path/to/cache', # cache folder
     13        component_root = '/path/to/templates', # templates folder
     14    )
     15
     16
     17def my_view(request):
     18     response = HttpResponse() # A file-like object
     19     interpreter.execute('mytemplate.myt', out_buffer = response)
     20     return response
     21}}}
     22It will use selected template.
     23
     24You may also pass variables to the templates like this:
     25{{{
     26interpreter.execute('mytemplate.myt', out_buffer = response, request_args = {'foo' : 'banana'})
     27}}}
     28for a template looking like this:
     29{{{
     30<%args>
     31 foo
     32 </%args>
     33 
     34%m.write(foo)
     35}}}
Back to Top