Pitmairen/hamlish-jinja — Issue #6: classes with '-' sign not accepted
Author: slapers
Created: 2011-11-09 11:07:23+00:00
State: open

Hi,

I really like the library you wrote, using it with paramid. I encountered a little issue with classes containing the '-' character.

The following doesn't work:

%div.icon.fugue-building

In the generated html, this translates to

The problem is related to the regex in Hamlish.def _parse_shortcut_attributes(self, attrs):

match = re.findall(r'([\.#])(\w+)', value)

Perhaps it can be changed to:

match = re.findall(r'([\.#])([\w-]+)', value)

Testing the regex:

Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> match = re.findall(r'([\.#])(\w+)', 'div.test.test-ikke')
>>> print match
[('.', 'test'), ('.', 'test')]
>>> match = re.findall(r'([\.#])([\w-]+)', 'div.test.test-ikke')
>>> print match
[('.', 'test'), ('.', 'test-ikke')]
>>>