且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

mustache.js日期格式

更新时间:2022-04-10 07:28:23

由于其在客户端/服务器之间共享的能力,我也一直在使用Mustache.我最终要做的是在服务器端将所有值(日期,货币)格式化为字符串,因此我不必依赖于辅助Javascript函数.但是,如果您要针对客户端的这些值进行逻辑处理,那么这可能对您来说效果不佳.

I've been using Mustache for my projects as well, due to its ability to be shared across client/server. What I ended up doing was formatting all values (dates, currency) to strings server-side, so I don't have to rely on helper Javascript functions. This may not work well for you though, if you're doing logic against these values client-side.

您可能还想研究使用 handlebars.js ,它本质上是Mustache,但扩展名可能会有所帮助带有客户端格式(以及更多).这里的损失是,如果这对您来说很重要,您将可能找不到服务器端实现的把手.

You might also want to look into using handlebars.js, which is essentially Mustache, but with extensions that may help with client-side formatting (and more). The loss here is that you will probably not be able to find a server-side implementation of handlebars, if that matters to you.