Code Monkey home page Code Monkey logo

ezformat's People

Contributors

co3moz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ezformat's Issues

Supporting objects

Objects in ezFormat

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.

Examples

var cost = new Cost(23, Cost.Dollars);
"Project cost: {.currency.symbol}{.value/fixed:2}".format(cost); // "Project cost: $23.00"

Other new features

  • if you want to print arg 0, you don't need to put any number there. It will transfer's it to 0.
    Ex: {/fixed} or {/s:3} or {.element}

Note:
This action won't work with just {}

  • you can use slash (/) for indicate type. It's easier to understand.
    Ex: {1/json} or {1:json} and {/json} or {:json}

Note:
You can use old one : too.

  • you can call functions with object accessor
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());

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.