Search code examples
angularjshamlhtml-encodehtml-escape-characters

Ampersand conversion with Haml with Angular.js application


I have an Angular.js application that I want to start using Haml with. My problem is some of my code doesn't convert properly.

I need to output the following:

<form name='userForm' class='admin-form form-horizontal' ng-submit='userForm.$valid && saveUser()' novalidate></form>

So in Haml, I write:

%form{:class => 'admin-form form-horizontal', :name => 'userForm', :'ng-submit'=>'userForm.$valid && saveUser()'}

The problem though is that the && gets converted to &amp;&amp; so:

<form name='userForm' class='admin-form form-horizontal' ng-submit='userForm.$valid &amp;&amp; saveUser()' novalidate></form>

What can I do to prevent this? Also, is it possible to put each attribute of a tag in Haml on a separate line? I get errors when I try to do that as well.


Solution

  • Alright, I got it to work by setting no-escape-attrs to true in the Gruntfile haml options:

    haml:
          options:
            'no-escape-attrs': true