co3moz / ezformat Goto Github PK
View Code? Open in Web Editor NEWEasy string formatting script for javascript
Easy string formatting script for javascript
With this new regex;
/\{[\t ]*([0-9]+)?[\t ]*(\.[a-zA-Z0-9.() \t]+)?[\t ]*(?:[:\/]([a-zA-Z0-9]*))?[\t ]*(?::(\d*))?[\t ]*}/g
now it will support object calling.
var cost = new Cost(23, Cost.Dollars);
"Project cost: {.currency.symbol}{.value/fixed:2}".format(cost); // "Project cost: $23.00"
{/fixed}
or {/s:3}
or {.element}
Note:
This action won't work with just{}
slash
(/
) for indicate type. It's easier to understand.{1/json}
or {1:json}
and {/json}
or {:json}
Note:
You can use old one:
too.
function Car() {
this.drive = function() {
var miles = Math.random() * 100 >>> 0;
return "I drive " + miles + " miles";
}
}
"Driving: {.drive()}".format(new Car());
Note:
We suggest you, use properties for this actions. don't use paranthesis as much as you can do.function Car() { Object.defineProperty(this, "drive", { get: function() { var miles = Math.random() * 100 >>> 0; return "I drive " + miles + " miles"; } }); } "Driving: {.drive}".format(new Car());
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.