简体   繁体   English

Jekyll /液体方式来打印带有分隔符的数字?

[英]Jekyll/Liquid way to print numbers with separator character?

I am printing large numbers in Jekyll (powered by Liquid), which by default does not perform any sort of formatting. 我正在Jekyll(由Liquid支持)中打印大量数字,默认情况下,该格式不执行任何格式设置。 I'd like to print integers with separator characters, eg render 12000 as 12,000 . 我想打印带有分隔符的整数,例如将12000渲染为12,000

I've looked for a filtering option in Liquid that supports this to no avail. 我一直在Liquid中寻找一种过滤选项,但无济于事。 Do I need to write my own extension/filter and do this myself? 我需要编写自己的扩展名/过滤器并自己执行此操作吗?

It does not look like there is a built-in filter to do this, and as "Virtua Creative" mentioned in a comment Shopify provides a JavaScript library for doing locale-specific number formatting. 看起来似乎没有内置过滤器可以执行此操作,正如注释中提到的“ Virtua Creative”一样,Shopify提供了一个JavaScript库,用于进行特定于区域设置的数字格式设置。 (Which makes sense, since the Jekyll code is generated with zero context of the environment where it will be read.) (这是有道理的,因为Jekyll代码是在零环境下生成的,该环境将被读取。)

So creating a plug-in is your best bet. 因此,创建插件是您最好的选择。 However, it appears that a plug-in already exists to do this (and other basic types of filtering). 但是,似乎已经存在执行此操作的插件(和其他基本过滤类型)。 See: 看到:

https://github.com/23maverick23/jekyll-humanize https://github.com/23maverick23/jekyll-humanize

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM