变量创建问题
Variable Creation Issues
我正在使用 freemarker 引擎在 Netsuite 中创建一个快速模板(我第一次接触它),我正在努力寻找正确的语法来执行以下操作。
我有以下两个变量
item.rate & item.custcol_uom
我需要做以下事情
${formatAmount(item.rate/item.custcol_uom,"currency",".")}
如有任何帮助,我们将不胜感激。
Freemarker 为包括货币在内的数字提供了多种格式指令
${(item.rate/item.custcol_uom)?string.currency}
在此处查看文档:http://freemarker.org/docs/ref_builtins_number.html
如果出于某种原因您更喜欢使用方法 formatAmount()
您应该将其公开给 freemarker 引擎
另一个解决方案是创建一个 freemarker macro
<@macro format_amount rate uom >
<#-- stuff here -->
</@macro>
不如叫它
<@s.format_amount rate=item.rate uom=item.custcol_uom />
freemarker 中的宏:http://freemarker.org/docs/ref_directive_macro.html
希望对您有所帮助。
我正在使用 freemarker 引擎在 Netsuite 中创建一个快速模板(我第一次接触它),我正在努力寻找正确的语法来执行以下操作。
我有以下两个变量
item.rate & item.custcol_uom
我需要做以下事情
${formatAmount(item.rate/item.custcol_uom,"currency",".")}
如有任何帮助,我们将不胜感激。
Freemarker 为包括货币在内的数字提供了多种格式指令
${(item.rate/item.custcol_uom)?string.currency}
在此处查看文档:http://freemarker.org/docs/ref_builtins_number.html
如果出于某种原因您更喜欢使用方法 formatAmount()
您应该将其公开给 freemarker 引擎
另一个解决方案是创建一个 freemarker macro
<@macro format_amount rate uom >
<#-- stuff here -->
</@macro>
不如叫它
<@s.format_amount rate=item.rate uom=item.custcol_uom />
freemarker 中的宏:http://freemarker.org/docs/ref_directive_macro.html
希望对您有所帮助。