The following code gives me unbalanced bracket error at line 4
%ul
  - @sentences.each do |sentence|
    %li
      %a{id:"s-#{sentence.id}",
      href:"/sentence/#{sentence.id}",
      'data-type' => 'text',
      'data-url' => "/sentence/#{sentence.id}",
      'data-toggle' => 'manual'
      }= sentence.content
      %a{href:'#'}
        %i.icon-pencil
Haml::SyntaxError at /user/1/sentence
Unbalanced brackets.
file: sentences.haml location: nil line: 4
any idea?
I found the problem myself, the closing } should not in a new line like any other languages
'data-toggle' => 'manual'}
  = sentence.content
will work
I found other solution it may work for the others. According to the docs it is required to use | on multiline content. Of course closing bracket can't be in the new line. Example:
  %a{id:"s-#{sentence.id}", |
  href:"/sentence/#{sentence.id}", |
  'data-type' => 'text', |
  'data-url' => "/sentence/#{sentence.id}", |
  'data-toggle' => 'manual'}= sentence.content
This one worked for me. Try adding a comma after your last key-value pair.
For instance
...
 'data-url' => "/sentence/#{sentence.id}",
 'data-toggle' => 'manual',
}
Note the , after 'manual'. This worked for me. Hope it helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With