Version 1 (modified by 18 years ago) ( diff ) | ,
---|
Using Myghty templates in Django is easy.
- Install Myghty - Myghty.org
- edit yours views like this:
import myghty.interp as interp from django.http import HttpResponse interpreter = interp.Interpreter( data_dir = '/path/to/cache', # cache folder component_root = '/path/to/templates', # templates folder ) def my_view(request): response = HttpResponse() # A file-like object interpreter.execute('mytemplate.myt', out_buffer = response) return response
It will use selected template.
You may also pass variables to the templates like this:
interpreter.execute('mytemplate.myt', out_buffer = response, request_args = {'foo' : 'banana'})
for a template looking like this:
<%args> foo </%args> %m.write(foo)
Note:
See TracWiki
for help on using the wiki.