blikblum / tinybind

Lightweight and powerful data binding + templating solution
http://blikblum.github.io/tinybind/
MIT License
79 stars 14 forks source link

Adding the rivets standard library. #22

Open RobertZenz opened 4 years ago

RobertZenz commented 4 years ago

Rivets is sporting a stdlib with quite a few useful functions.

Would it be worthwhile to port this tinybind and add it as (optional) addon to this repository? So that you get "tinybind.js" and "tinybind-stdlib.js" as files out of the build process?

matthieuriolo commented 2 years ago

@RobertZenz @bart112233 Sorry for being so extremely late to the party! I'm the owner of stdlib which I created because I realized that there are formatters which I used regularly and I end up copy&pasting them between projects. I used to. I dont really use rivetsjs anymore :)

Considering how old this issue is I doubt that any of you are still interested in this feature?

If you do, it should be rather simple to adjust rivetsjs.stdlib to work with tinybindjs. Essentially you should be able to replace the term "rivets" with "tinybind" at https://github.com/matthieuriolo/rivetsjs-stdlib/blob/354bf7395b68b0d6e823b750d0cc92581325279a/src/rivetsstdlib.js#L22

Formatter defintion in tinybind (injection place) https://github.com/blikblum/tinybind/blob/master/dist/tinybind.js#L105-L109

karneaud commented 1 year ago

@matthieuriolo

thanks for this and would appreciate a fork with a test case for review via pull request

RobertZenz commented 1 year ago

Considering how old this issue is I doubt that any of you are still interested in this feature?

To be honest, I'm not even sure what exactly I wanted to use tinybind for. However, I do remember that I at least created a prototype and that it was a joy to use.

Looking at the locations pointed out by @matthieuriolo I've got a slightly different idea, it seems like something like this might be a simple solution:

    }else {
        // Browser globals
        if (root.rivets !== undefined) {
            factory(root.rivets, root.moment);
        }

        if (root.tinybind !== undefined) {
            factory(root.tinybind, root.moment);
        }
    }

Meaning that the Standardlib would support being injected into both, rivets and tinybind. Obviously this only works as long as rivets and tinybind stay compatible...but I guess we could agree on that?

matthieuriolo commented 1 year ago

@RobertZenz: Glad to hear that you enjoyed it. Rivetsjs used to be big back in the days 🙂 I just looked more closely at the code that I referenced and I made a mistake. If you read the lines above then you will see that stdlib supports CommonJS modules. This has been replaced by ECMAScript modules and my code is very outdated...

@karneaud: Rivetjs had the principle of being "small". Hence it did not offer any formatters out of the box. I could image that this statement isnt true with tinybind anymore? If so, copying the stdlib formatters into formatters.js would be a simple solution.