Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法以某种方式使用 %def 引用,基本思想是:
% if condition_a: % func = %def_a % elif condition_b: % func = %def_b ... etc ... ${func( params )}
是的,像这样:
% if condition_a: <% func = def_a %> % elif condition_b: <% func = def_b %> % endif ${func( params )}
@timmy:我不明白你的意思,也许是这个?
<% func = some_dict[key] %> ${func( params )}
您可以将任何 Python 代码放入<% .. %>其中,请参阅 mako 文档!
<% .. %>