4 ms·
The approach we've taken in our anti-framework is that the model is your data (and the code you use to manipulate the data), the view is your HTML/CSS (not a sp
by Tloewald 13y ago
The approach we've taken in our anti-framework is that the model is your data (and the code you use to manipulate the data), the view is your HTML/CSS (not a special templating language -- actual HTML), and the controller is automatic for simple stuff and custom for complex stuff.
So the big example at the end of Mithril would, for us, be something like (we implement binding as a jQuery extension)
$('.display').bind(data);
Where .display selects the root node of the bound UI, and data is our object.
Which is simpler and less code, I think. (Oh and our binding library has jQuery as a dependency, but is sub 3kB minified and gzipped.)
That said, we haven't put our libraries on github yet :-(
- jedahan 13y agoI want this
- buckbova 13y agoSounds a bit like the pure js library but with jquery. http://beebole.com/pure/ http://beebole.com/pure/
- Tloewald 13y agoOurs is a fair bit more elegant and works both ways. It's also being used for multiple pretty complex projects so it's reasonably "battle-tested" (although nothing is in production yet, so not as battle-tested as it needs to be). We also do not bind by class because that's a really bad idea. (Actually the way we bind is a lot like Angular, but without being a templating language.) A key design requirement is that the model does not get polluted with special methods and properties to support the binding -- so (for example) if you have nice RESTful services, you can GET, bind, edit, POST/PUT and everything just works. For moderately complex cases we support "decorators" that live "off to the side" (i.e. do not pollute the model). Again, you can stick getters and setters in your model if you want to, you just don't need to.
- ulisesrmzroche 13y agoYou're not using actual HTML, you're wrapping dom elements in your own special functions. You've made a templating langauge, like it or not.
- Tloewald 13y agoAm I using code to do binding? Yes. Do we bind to HTML or something that -- after being parsed -- turns into HTML? HTML. The advantages are significant. First -- you have to know HTML. Second -- all the code that works on HTML works on HTML. We use data attributes to make the binding work. The data attributes are a "template language" if you will, but it's not breaking HTML (and if you read our attributes they make sense without much documentation).
- ulisesrmzroche 13y agoNo, if you're compiling at some point into HTML, then by definition, you're not writing HTML. HTML doesn't have functions in its spec (function m()) That's breaking HTML right there.