Ember.js: HtmlBars and the Handlebars.compile command

后端 未结 3 1799
生来不讨喜
生来不讨喜 2020-12-16 21:58

I get the following error when running my app:

Uncaught Error: Cannot call `compile` without the template compiler loaded. Please load `ember-template-compil         


        
3条回答
  •  太阳男子
    2020-12-16 22:47

    For my views, I just created template files for them. To use your case as an example, I would create app/templates/views/carousel.hbs:

    {{view view.itemsView}}
    

    Then CarouselView becomes:

    var CarouselView = Ember.View.extend({
      templateName: 'views/carousel',
      elementId: 'carousel',
      contentBinding: 'content',
      ...
    

    This way you don't have to give the client the template compiler. Should result in better performance and a smaller payload for the client to download.

提交回复
热议问题