On 1/12/08, huntercross <[EMAIL PROTECTED]> wrote:
>
>
> i searched the documentation and the group, but couldn't find an
> answer. hopefully it is an easy one.
> i want to implement a function called nice_telephone() in my templates
> that formats
> telephone numbers pulled from the database.
>
> here is my code.py...
>
> render = web.template.render('/removed/httpd/htdocs/templates/',
> cache=False)
> web.template.Template.globals['nice_telephone'] = nice_telephone
>
>
> then the the function is below that a ways...rearrange your code. move the function definition to be above the template globals. looks like this is the only problem. def nice_telephone(t): > st = str(t) > > ret = st[0:2] + '-' + st[3:5] + '-' + st[6-8] > > print ret > > > then in the template file we have: > > <span class="edit" id="resume_telephone"> > $:nice_telephone(resume.resume_telephone)</span> > > the error i get is: > <type 'exceptions.NameError'> at /admin/edit/46 > could not find 'nice_telephone' (line 28) > > > > what am i messing up? thank yo ufor all your help, i love web.py! > > > -- ashok raavi --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web.py" 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/webpy?hl=en -~----------~----~----~----~------~----~------~--~---
