thanks Ben, your explanation really helps.  what I wanted was simply to
have function available to my template.   The more i look at pylons the
cooler it gets thaks
Jose

Ben Bangert wrote:
> On Jun 6, 2006, at 10:43 PM, Jose Galvez wrote:
>
>   
>> Ive got a quick templating question.  I'm using cheetah as my template
>> and what I want to is use function in my class within the template to
>> post process data and present it better.  In webware this is really  
>> easy
>> I just pass self to the template in the namespaces.  Can I do  
>> something
>> similar with cheetah in pylons?
>>     
>
> Sure, though I've generally been extremely wary of calling controller  
> methods from a template. Do you really need the controller instance  
> in your template, or do you want a way to have functions in the  
> template's namespace?
>
> If you want to add functions for use in your templates, any function  
> you define in yourproj/lib/helpers.py is available under the h.  
> variable. That module is imported and has all the names in it  
> attached to 'h', so you can see in there how the WebHelper methods  
> got brought in as well. If you're curious about what WebHelper  
> functions are already available, a list with docs is here:
> http://pylonshq.com/WebHelpers/module-index.html
>
> By default, the full webhelpers import statement imports all the  
> functions from the various webhelpers.rails modules.
>
> If you want to pass the controller instance itself into your  
> template, I'd suggest just adding a reference to it to the 'c'  
> variable which will be present in your template. Ie, in your  
> controllers action:
>      c.self = self
>      return render_response('/some/template')
>
> If you want to add variables directly to the template namespace  
> instead of tacking them onto 'c':
>      return render_response('/some/template', cont=self)
>
> All keywords to the render command will be added to your templates  
> namespace.
>
> HTH,
> Ben
>
> >
>
>   


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

Reply via email to