Re: [Rest2web-develop] How to use custom macro in template files ?
Brought to you by:
mjfoord
|
From: Michael F. <fuz...@vo...> - 2007-01-30 23:32:33
|
David Cournapeau wrote:
> Hi there,
>
> I am using rest2web for my own website, and it is working great, but
> I have one problem. I would like to use my own python functions in the
> templates, and I don't know how to do that. I manage to use my macro in
> a index file doing {print_hello}, but I cannot make it work in a
> template.txt (using <# print_hello() #>).
This should work. You should either import or define the function in the
template. The function needs to print its output rather than simply
return it (unless you use <% print_hello() %>).
Try something like:
<#
def print_hello():
print 'hello'
print_hello()
#>
Fuzzyman
http://www.voidspace.org.uk/python/articles.shtml
> I thought about adding it in
> the namespace using uservalues:
>
> [uservalues]
> foo = print_hello
>
> But print_hello is transformer into a string before the template is
> processed. So how can I use my own python function in a template file ?
>
> Thanks,
>
> David
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Rest2web-develop mailing list
> Res...@li...
> https://lists.sourceforge.net/lists/listinfo/rest2web-develop
>
>
|