Html 如何在swig模板中进行舍入

Html 如何在swig模板中进行舍入,html,node.js,swig-template,Html,Node.js,Swig Template,我正在使用swig模板在我的组织中发送自动邮件。 我在谷歌上搜索了所有东西,但找不到任何关于如何在swig中舍入价值的信息。 我的代码是: <td style="background:#ff4d4d;text-align: center;padding: 7px 24px;border-radius: 5px;color: #fff;font-size: 18px;">{{cnt.p/cnt.total*100 }}%</td> {{cnt.p/cnt.total*10

我正在使用swig模板在我的组织中发送自动邮件。 我在谷歌上搜索了所有东西,但找不到任何关于如何在swig中舍入价值的信息。 我的代码是:

<td style="background:#ff4d4d;text-align: center;padding: 7px 24px;border-radius: 5px;color: #fff;font-size: 18px;">{{cnt.p/cnt.total*100 }}%</td>
{{cnt.p/cnt.total*100}}%

在这里,我想把“{{cnt.p/cnt.total*100}}”四舍五入到小数点后两位。请帮助实际上,您可以在Swig中使用
{}
中的任何JavaScript语句。在这种情况下,代码为:

<td>{{Math.round(cnt.p/cnt.total*10000)/100}}%</td>
{{Math.round(cnt.p/cnt.total*10000)/100}%
但是,请注意,不再维护。建议使用Mozilla的,它的语法非常类似于Swig