nested quotes in haml

467 Views Asked by At

I'm trying to convert my knockoutJs html code to HAML, trying to achieve something after compilation like:

<div data-bind="attr: { 'data-something': someValue }">...</div>

So I try:

%div{data:{bind:"attr: { 'data-something': someValue }"}}

But using haml_assets 0.1.0 I get:

<div data-bind="attr: { "data-something': someValue }'>...</div>

So my last resort was go back to:

== <div data-bind="attr: { 'data-something': someValue }">...</div>

Is this a bug in HAML, and/or is there a neater way to achive this?

2

There are 2 best solutions below

0
bert bruynooghe On BEST ANSWER

This is an issue on haml_assets 0.1.0. A ticket was created for this: https://github.com/infbio/haml_assets/issues/10

There is also a better workaround for it until it is fixed:

%div{data:{bind:'attr: { "data-something": someValue }'}}
1
John Earles On

Try this:

%div(data-bind="attr: { 'data-something': someValue }")

When I did this in a RoR app that uses HAML I get this rendered:

<div data-bind="attr: { 'data-something': someValue }"></div>