开发者

Getting %def references in mako python

is there a way to use %def references somehow, basic idea being:

% if condition_a:
%    func = %def_a
% elif 开发者_Python百科condition_b:
%    func = %def_b
... etc ...

${func( params )}


Yes like this:

% if condition_a:
<% func = def_a %>
% elif condition_b:
<% func = def_b %>
% endif

${func( params )}

@timmy: I have no idea what you mean, maybe this?

<% func = some_dict[key] %>
${func( params )}

You can put any Python code inside <% .. %>, see the mako docs!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜