Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class attribute interpolation #40

Closed
AlexanderPavlenko opened this issue Apr 27, 2012 · 1 comment
Closed

Class attribute interpolation #40

AlexanderPavlenko opened this issue Apr 27, 2012 · 1 comment

Comments

@AlexanderPavlenko
Copy link

> test1 = '
  - for i in [1..5]
    %i{:class => "prefix-#{i}"}'

> HamlCoffeeAssets::HamlCoffee.compile 'test1', test1, false
=> "(function(context) {\n  return (function() {\n    var $o, i;\n    $o = [];\n    for (i = 1; i <= 5; i++) {\n      $o.push(\"<i class='prefix-\" + i + \"'></i>\");\n    }\n    return $o.join(\"\\n\").replace(/\\s(\\w+)='true'/mg, ' $1').replace(/\\s(\\w+)='false'/mg, '');\n  }).call(HAML.context(context));\n});"

> test2 = '
  - for i in [1..5]
    %i.other{:class => "prefix-#{i}"}'

HamlCoffeeAssets::HamlCoffee.compile 'test2', test2, false
=> "(function(context) {\n  return (function() {\n    var $o, i;\n    $o = [];\n    for (i = 1; i <= 5; i++) {\n      $o.push(\"<i class='\" + (['other', i].sort().join(' ')) + \"'></i>\");\n    }\n    return $o.join(\"\\n\").replace(/\\s(\\w+)='true'/mg, ' $1').replace(/\\s(\\w+)='false'/mg, '');\n  }).call(HAML.context(context));\n});"

In first case we are getting expected class=("prefix" + i), but in the second case prefix is omitted: class=(['other', i].sort().join(' '))

@netzpirat
Copy link
Collaborator

Thanks for reporting. It has been fixed in Haml-Coffee 0.6.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants