Looking for a javascript framework that provides templating & data binding that are not MVC [closed]


I've looked at AngularJS and Backbone.JS both look like great frameworks, however my existing code base does not use the MVC pattern. Both of those frameworks force you to either start from scratch or refactor your entire code base to follow the MVC pattern.

Almost all of my data is custom objects with many myobject.prototype.myfunction = ... then serialized to/from JSON and stored on the server and jquery templates to render.

Right now i use jquery templates and they work great. In all fairness I have no problem with using them except I really don't like the mixing of business logic and DOM elements. If jQuery templates simply had two way data binding I would be in heaven, but at this point in time they don't. I know jsRender and jsViews look promising but their future is not set in stone yet and not ready for production. I need something I can build production code on today and support and grow with and not have to rewrite/refactor every two years.

So musts:

  • jquery compatible
  • be end to end testable
  • data binding
  • use existing javascript objects
  • doesn't require major refactoring

P.S. If my opinion of Angular or Backbone is ill informed, then please point me in the right direction.

By : ethermal

The Data Link plugin was designed to be used with jQuery templates, although both are no longer supported. The code, and examples, can be found on the project's github page.

As noted, the author plans to replace these with a new project called jsViews

Knockout.JS is a popular data-binding framework that was originally designed with jQuery templates in mind. It still supports them, although it has since implemented its own template system. Check out the video of Steve Sanderson's lightning talk for a demo of Knockout and jQuery templates in action.

By : Darren

Loving jsRender and jsViews

This is actually a fork of jquery.tmpl. Same author. They are still pre release but becoming new standard and hopefully will be reintegrated back to jquery sometime in the future.

By : Dimitri

For a framework agnostic solution towards template binding do checkout Rivets.js . While Rivets can be used with most of the popular MVC frameworks/micro-frameworks - it is also easy to work with if you are not using any MVC framework, as is your case. However Rivets.js does not come with built in support for any templating language per se.

If you really wish to continue using JQuery.tmpl I would recommend you (like some of the people above) to take a look at KnockoutJS . Do keep in mind that if you switch to KnockoutJS, given the pattern of demonstrative examples - it is quite easy to intermingle domain logic right inside your declarative bindings. So it would require a bit of planning to keep complete isolation of business logic and presentational layer. Apart from the official website, for obtaining a better understanding of Knockout JS I recommend you checkout knockmeout.net for some indepth resources. Also this post might help you in your decision.

Considering that the future of jquery.tmpl is somewhat questionable as of this writing, I would recommend you to look out for other solutions. KnockoutJS can be integrated with third party templating languages with ease.

By : lorefnon

This video can help you solving your question :)
By: admin