Choosing the right UI templating tool - dust.js? [closed]

拜拜、爱过 提交于 2019-12-02 14:08:28
g13n

Dust.js is a good option. It is better than some of the other templating frameworks because it does not constrain that the data should be in a file, or in a string, etc.

Also it is being actively maintained https://github.com/linkedin/dustjs.

  1. Has it been successful?

    Yes, I know at least LinkedIn is using it and also contributing improvements/patches, etc.

  2. Is it easy to use?

    I have tried using it and it is as easy as Mustache or Handlebars.js.

  3. Is it sufficiently documented?

    Yes http://akdubya.github.com/dustjs.

  4. Is community support good? (only 6 questions on ST tagged 'dust.js'!)

    If you are comparing Mustache or Handlebars.js, dust.js does not have as many users, but I believe if you have an issue and post it on the LinkedIn repo they would definitely respond. I will too since I'm watching it :-)

  5. What are the pros and cons when compared to other templating tools such as Underscore's templating, Google Closure Templates, Handlebars and Mustache.

    As for pros, you can check when you should consider using dust.js here https://github.com/linkedin/dustjs#readme.

    As for cons, there aren't enough users for dust.js compared to popular ones like Mustache or Handlebars.js. That said, the other libraries like Google Closure suffer the same problem.

    But like I mentioned before, dust.js is designed very well compared to other frameworks IMHO.

  6. Are there any problems using it with an MV* structure framework, e.g Backbone.js (online book)?

    I have not used it with other MVC frameworks, but I don't think it should be a problem at all.

Hope that helps.

  1. I'm doing a freelance project now for quite a big and established niche IT company and they've chosen dust.js for their HTML5 mobile app framework. And yes, LinkedIn is a big and successful company.

  2. Sort of. Nothing really difficult but I needed to get accustomed to it. I worked with Freemarker on Java - Freemarker seemed quite a bit easier to use because of a lot of built-in power features. However, many may find dust.js nice - it has its clear logic, very lightweight syntax - there are things in dust.js to really like for many.

  3. Freemarker for Java was documented much better. dust.js's GitHub page is very OK for starters but, for example, I couldn't find the description of all the dust.js filters there and needed to search on Google for it - however, that search easily provided me with the info I needed.

  4. Didn't see much community support but the library is really lightweight and clear - a couple of Google searches was all I needed to gather all the necessary info.

  5. Didn't use other JS templating tools.

  6. The company I mentioned in the answer to the 1st question has built a lightweight HTML5 framework using dust.js together with both jQuery and Backbone.js. I'm doing the project for them using that framework and tapping to both jQuery and Backbone.js functionality all the time - nothing to complain about. dust.js is a little bit like Backbone.js - lightweight and not imposing much restrictions on your coding style or other libraries you use. Using it you will see that there is some preferrable form of JS objects you use to feed it with the data but it's easy to get accustomed to (I mean if you need lists of something in your views it's better to feed dust.js with lists and not JS object hashes which at the same time are natural at describing separate entities).

One thing about performance - you can develop your app with "full" version and then compile your templates for production (using for example node.js + dust.js npm module - grunt can be useful here) to be used with "core" version. In this case you could get quite a boost in real-world performance - putting all the templates together and minifying them will free the client browser from fetching the templates from server every time it needs them. "Full" and "core" are not about commercial/free - the core version just doesn't have the template compiler and is to be used with pre-compiled templates.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!