Is it possible to use the Handlebars.js with the Backbone.Marionette extension without reimplementing the Views render function? It seems that Marionette is relying on the convention that you use Backbone.js with underscores templating engine. But I really like the handlebar approach so I'm asking if I can the high-level-tools of Marionette with handlebars.
相关问题
- Backbone.js PushState routes .htaccess only workin
- Updating a LayoutView's Model
- Disable Backbone.js hashes entirely, but keep push
- ember component based on model type
- Is there an easy way to distribute a Flask server
相关文章
- Get all models in backbone collection where attrib
- How to use autofocus with ember.js templates?
- How can I dynamically set a className for a Backbo
- Nesting Views within Views in backbone js
- Backbone-relational hasmany best practices
- JavaScript error: “is not a constructor”
- Marionette + i18n in templates
- Rendering reCAPTCHA v2.0 widget within Backbone vi
We can also make use of precompiled templates here.
This way we can remove the compilation role from Marionette.
The current two answers do not exploit caching. Use this gist instead.
@brettjonesdev is correct, but one other addition here that I found worked well was:
This helps when searching the DOM.
A simple way to use Handlebars with Marionette is simply to define
template
in each View as a pre-compiled Handlebars template function. For instance:Marionette's default
Renderer
will detect that thetemplate
attribute is a function, and will call it accordingly.See also the official documentation about this case : https://github.com/marionettejs/backbone.marionette/wiki/Using-handlebars-templates-with-marionette
and an other Q/A with requirejs + Marionette + Handlebars precompiled : Using precompiled handlebars templates with Marionette