我正在尝试将 HAML 与车把一起使用,但事情无法正常工作,从而产生以下错误:
Assertion failed: Expected hash or Mixin instance, got [object Function]
以下是我的观点:
%br
%h2 Replies
%table{:class => "table table-striped"}
%thead
%tr
%th Id
%th Description
%th User
%th Actions
%tbody
- @ticket.note.each do |note|
%tr
%td= note.id
%td= note.description
%td= note.user.name
/ %td= link_to 'Edit', edit_note_path(note), :class => "btn btn-small"
%td <script type="text/x-handlebars">{{#linkTo 'notes'}}Edit{{/linkTo}}</script>
= link_to 'New', new_note_path, :class => "btn btn-primary"
我正在尝试做的是仅在编辑链接上使用车把并将其连接到 Ember.js
最好的方法是什么?
虽然问题可能与 Ember 有关,但在 HAML 中编写 script
标记以保持一致:
%td
%script{:type => "text/x-handlebars"}
{{#linkTo 'notes'}}Edit{{/linkTo}}
我认为这个错误与 haml 无关。当您尝试扩展类并且某些值不是javascript对象或mixin时,就会发生这种情况。在您的情况下,即将出现一个功能。
// some mistake set a function to this
App.MyMixin = function() {}
// here will crash
App.SomeView = Ember.View.extend(App.MyMixin, {
title: '...'
});