arnaud-lb / MtHaml

Multi target HAML (HAML for PHP, Twig, <your language here>)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Providing attributes as a variable results in dropping predefined classnames: `.foo{$atts}` removes the `foo` class

lolmaus opened this issue · comments

Example of correct behavior

MtHaml:

- $class = 'bar'
.foo{'class' => $class} Baz

Output:

<div class="foo bar">Baz</div>

Example of buggy behavior

MtHaml:

- $attrs = array('class' = 'bar')
.foo{$attrs} Baz

Expected output:

<div class="foo bar">Baz</div>

This is how vanilla Haml works: http://sassmeister.com/gist/466bdb71c5af3414bbd9

Actual output:

<div class="bar">Baz</div>

Can you please fix this quickly? 😭

Thanks for your report. I'll try to find time to fix this (unless someone submits a pull-request before I do :) ).

In the meantime, here is a workaround:

.foo{class=$attrs['class']} Baz

I've outlined this workaround in the post. Unfortunately, it's not an option because it prevents from applying a dynamically generated list of attributes.

Have to use this workaround instead:

- $args['class'] = 'my-element' . (array_key_exists($args, 'class') ? ' ' . $args['class] : '')
%div{$args} Foo

Very ugly. :(

Fixed, thanks for your detailed report

My pleasure. ^______^