Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #93769

Re: A webpy Templetor question

References <fc88437a-7776-4836-a57e-10c67e8f5925@googlegroups.com>
Date 2015-07-14 10:59 +1000
Subject Re: A webpy Templetor question
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.473.1436835551.3674.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jul 14, 2015 at 9:13 AM,  <yongzhi.chen@gmail.com> wrote:
> #in my application.py:
> def checknow():
> ...
>     return TN_str
>
> render = web.template.render('templates/',globals={'stat':checknow})
>
> #in the template:
> $def with(checknow)
> ... ...
>     <h1><div>Test: $stat(checknow)</div></h1>

You've effectively taken a reference to the checknow function and
given it the name 'stat'. So when you call $stat(), I would expect it
to call checknow() with exactly those arguments. I don't know what
"$def with(checknow)" means, but if you figure out what checknow is
inside there, then you'll know whether you want any argument at all. I
suspect just "$stat()" may well do what you want.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

A webpy Templetor question yongzhi.chen@gmail.com - 2015-07-13 16:13 -0700
  Re: A webpy Templetor question Chris Angelico <rosuav@gmail.com> - 2015-07-14 10:59 +1000

csiph-web