backbone.jshandlebars.jsclient-side-templating

Why should i use Handlbars Templates in BackboneJS application instead of underscore templates?


I have seen many people using handlebars templates with BackboneJS instead of underscore templates, even underscore is hard dependency of BackboneJS. Can anyone please tell me benefits of doing so?


Solution

  • Handlebars:

    1. Compatible with mustache templates - what cam be used to use same syntax, or even templates
    2. More readable syntax

    Underscore:

    1. No need to load extra library for template
    2. Underscore its not only template engine. It has 80+ useful functions for working with objects, arrays and collections.

    On my point of view there are a lot of advantages and disadvantages of using these libs according project specifics.