Dear Malcolm thanks a lot I found this in webpy for generating cheetah templates by default I call web.render('index.html')
Can you tell me where I can use this in Django or what part of django i need to use. As you can see I m fairly a newbie Thanks Anil index.html 1675 def render(template, terms=None, asTemplate=False, base=None, 1676 isString=False): 1677 """ 1678 Renders a template, caching where it can. 1679 1680 `template` is the name of a file containing the a template in 1681 the `templates/` folder, unless `isString`, in which case it's the 1682 template itself. 1683 1684 `terms` is a dictionary used to fill the template. If it's None, then 1685 the caller's local variables are used instead, plus context, if it's not 1686 already set, is set to `context`. 1687 1688 If asTemplate is False, it `output`s the template directly. Otherwise, 1689 it returns the template object. 1690 1691 If the template is a potential base template (that is, something other templates) 1692 can extend, then base should be a string with the name of the template. The 1693 template will be cached and made available for future calls to `render`. 1694 1695 Requires [Cheetah](http://cheetahtemplate.org/). 1696 """ 1697 # terms=['var1', 'var2'] means grab those variables 1698 if isinstance(terms, list): 1699 new = {} 1700 old = upvars() 1701 for k in terms: 1702 new[k] = old[k] 1703 terms = new 1704 # default: grab all locals 1705 elif terms is None: 1706 terms = {'context': context, 'ctx':ctx} 1707 terms.update(sys._getframe(1).f_locals) 1708 # terms=d means use d as the searchList 1709 if not isinstance(terms, tuple): 1710 terms = (terms,) 1711 1712 if not isString and template.endswith('.html'): 1713 header('Content-Type','text/html; charset=utf-8', unique=True) 1714 1715 compiled_tmpl = _compiletemplate(template, base=base, isString=isString) 1716 compiled_tmpl = compiled_tmpl(searchList=terms, filter=WebSafe) 1717 if asTemplate: 1718 return compiled_tmpl 1719 else: 1720 return output(str(compiled_tmpl)) Malcolm Tredinnick wrote: > On Sat, 2006-09-30 at 09:42 +0000, anil wrote: > > import and use Cheetah's > > > template-loading and rendering functions instead of Django's. > > can you give me an example of how to do this > > The Cheetah website gives a simple example of how to produce output from > Cheetah templates ([1]). In Django, you collect the data you want to put > into your output in the normal fashion and then instead of calling > render_to_response() creating a Django template, you create a Cheetah > template and extract the string representation from that, just as in > their example. Then you pass that string to an HttpReponse object in > Django (see [2] and [3], replacing the Django templates with your > Cheetah output instead). > > In short, everywhere you would normally pass in the result of rendering > a Django template, you instead pass in the result of rendering a Cheetah > template. You won't be able to use the render_to_response() shortcut, > since that uses the Django template system, but it is only, after all, a > shortcut, so writing your own version that uses Cheetah templates would > be a matter of two or three lines of code. > > [1] > http://www.cheetahtemplate.org/docs/users_guide_html_multipage/gettingStarted.tutorial.html > > [2] > http://www.djangoproject.com/documentation/tutorial3/#write-views-that-actually-do-something > > [3] > http://www.djangoproject.com/documentation/request_response/#httpresponse-objects > > Best wishes, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---