haml problem with hashes and string interpolation

44 views
Skip to first unread message

jevado

unread,
Apr 4, 2007, 7:16:22 AM4/4/07
to Haml
Hello,

When I do something like the following, I'm getting a syntax error

%div{:class => "test"}= "#{something}somestring"

There's a workaround:

%div{:class => "test"}
= "#{something}somestring"

This works correctly.

Just wanted to let you know.

Kind regards,
Jeroen van Doorn

Nathan Weizenbaum

unread,
Apr 4, 2007, 1:17:08 PM4/4/07
to ha...@googlegroups.com
This is a known bug. It's due to a weakness in Ruby regular expressions
- they're unable to deal with nested characters, like brackets or
parentheses. We had to either break

%div{:class => "test"}= "#{something}somestring"

or

%div{:class => "#{something}somestring"}= "test"

And we chose the former, because we wanted people to be able to embed
stuff in attribute strings easily.

Thanks, though.
- Nathan

Spongy

unread,
Apr 5, 2007, 5:57:36 PM4/5/07
to Haml
Hopefully this kind of issue might go away with Ruby 1.9 which uses a
more featured regular expression engine

Nathan Weizenbaum

unread,
Apr 5, 2007, 10:47:52 PM4/5/07
to ha...@googlegroups.com
I believe the Ruby 2.0 Regexp engine has constructs that are
specifically designed to deal with nested characters, which should make
this issue disappear.

- Nathan

Reply all
Reply to author
Forward
0 new messages