I use HAML to create templates for the Backbone.js application. I need to be able to insert <%= blah %> as an html a la attribute:
%a{:href => "myresources/<% id %>"} My Resource
and bring it out
<a href='myresources/<%= id %>' >My Resource</a>
in the html template. Unfortunately, HAML avoids the html options, leaving me with
<a href='#myresources/<%= id %>'>My Resource</a>
According to the HAML Reference '!' The operator can be used for unescaping strings, but not inside HTML attributes.
Also, I would use plaintext to display the anchor tag, but since the anchor tag is the root of this particular view, I lose all the benefits of using HAML.
Any help?
Update I didnβt mention it, but I use LiveReload to actually monitor my file system and run the haml compiler, and the option to disable HTML screens in tag attributes was set in LiveReload. <head slap> If someone else encounters this problem outside of LiveReload, you can also set the parameter :escape_attrs to false when configuring your HAML installation.
Bryan marble
source share