🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.python
2 messages
2 total messages Started by Witold Fri, 27 Aug 2010 07:34
Argumenty w Mako
#27652
Author: Witold
Date: Fri, 27 Aug 2010 07:34
34 lines
1540 bytes
Witam,

czytam, szukam i nie bardzo wiem jak w Mako
przekazać argument do zdefiniowanej funkcji.

Przykład:

from mako.template import Template
test = '''
<%!
     def funcja(arg):
         arg += 1
         return arg
%>
<table>
% for x in range(count):
     <tr><td>
         Lp. ${funkcja(${lp})} <--- Błąd
     </td></tr>
% endfor
</table>

'''

t = Template(test, lp=0, count=5).render()

no i w miejscu gdzie zaznaczyłem wywala SyntaxError.
Nie mogę znaleźć rozwiązania stąd prośba o pomoc.

Z góry dziękuję

--
Pozdrawiam,
Witold
Re: Argumenty w Mako
#27653
Author: Daniel Mróz
Date: Fri, 27 Aug 2010 16:11
18 lines
1371 bytes
On 27.08.2010, Witold <witold.bryla_nospam@gmail.com> wrote:
>          Lp. ${funkcja(${lp})} <--- Błąd
A czy nie powinno przypadkiem być:

	Lp. ${funkcja(lp)}

?
Jeśli jesteś wewnątrz ${}, to tam nie działa już interpolacja Mako.


Pozdrawiam
Beorn

-- 
Daniel 'Beorn' Mróz <beorn@alpha.pl>    http://127.0.0.1/beorn
[GIT d s:- a-@ C++++ UL++++$ P+ L++++ E--- W+ N+++ o? K- w---]
[O- M- V!  PS+ PE++ Y+ PGP++ t- 5  X R !tv b+ DI D++ G++ e h*]
[                          r++  y+                           ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads