1. Install myghty (http://www.myghty.org)
2. edit your views.
2a. The easy way to use mygthy templates is to render them and send the
result to a "Blank" django template which will show the results
a simple view:
##################################
from django.shortcuts import render_to_response
import myghty.interp as interp

interpreter = interp.Interpreter(
        data_dir = './cache', # path to cache dir
        component_root = '/path/to/myghty/templates',
    )

class AFile(object):
    """I'm a file :) from http://blog.zabiello.com""";
    __content = ''
    def write(self, txt):
        self.__content += txt
    def read(self):
        return self.__content

def myview(request):
        file = AFile()
        #execute a template
        interpreter.execute('mytemplate.myt', out_buffer = file)
        # show it via django template
        return render_to_response('index.html', {'content': file.read()})
#################################
Example myghty template:
#################################
%m.write('I am a Myghty template!')
<BR>
%for i in range(1,10):
loop<BR />
%
#################################

- How to pass data to myghty templates?
USE request_args, like:
interpreter.execute('mytemplate.myt', out_buffer = file, request_args =
{'foo' : 'banana'})

And in myghty it could look like this:
######################
<%args>
foo
</%args>

%m.write(foo)
######################


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to