我使用mako创建html模板。
我的模板,我有以下代码:
% for s in query['sandboxes']:
% for node in s['nodes']:
<table>
<tr>
<td>${node['node_name']}</td>
<td>${node['slowcall_count']}) / ${s['slowcall_count']}</td>
</tr>
</table>
% endfor
% endfor循环和显示工作,但它显示"30 / 100“,而不是实际的除法结果。
在搜索之后,我看到了这个 import in Mako template
然后尝试了下面的代码:
<td>
<%!
float(${node['slowcall_count']}) / float(${s['slowcall_count']})
%>但它给了我一个语法错误。折叠不会产生任何错误,但也不会显示任何内容:
<td>
<%!
float(1) / float(2)
%>有办法让我的部门运作吗?
发布于 2013-11-01 14:25:50
这应该在td标记之间工作:
${float(node['slowcall_count']) / float(s['slowcall_count']) }表达式可以出现在${}中。如下文所述:
http://docs.makotemplates.org/en/latest/syntax.html#expression-substitution
https://stackoverflow.com/questions/19717584
复制相似问题