my purpose is to change input field format from text to currency format (from 23000.45 to $ 2,3000.45 )
this is what i did:
i did find a javascript that can transfer number to currendy format (i don’t find anyother plugin that can do this).
/*\
title: Number.js
type: application/javascript
module-type: macro
returns a formatted number
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "number";
exports.params = [ { name: "value" }, { name: "country" }, { name: "style" }, { name: "currency" } ];
exports.run = function(value,country,style,currency) {
return Intl.NumberFormat( country||"en-US", { style:style||"decimal", currency:currency||"USD" } ).format(value);
};
})();
then, i followed the instruction here, Customizing EditTemplate field rendering
create blow two tiddlers
<$edit-text tiddler=<<currentTiddler>> field=<$macrocall $name="name" value=<<currentField>> country="en-US" style="currency" currency="USD"/> tag="input" type= "number"/>
i think the problem is the last tiddler, i don’t know how to call this JS marcro by using <<currentFiled>>
as Param