开发者

Getting %def references in mako python

开发者 https://www.devze.com 2023-01-18 04:47 出处:网络
is there a way to use %def references somehow, basic idea being: % if condition_a: %func = %def_a % elif 开发者_Python百科condition_b:

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

精彩评论

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