jeromegn / slang

Slim-inspired templating language for Crystal
MIT License
236 stars 30 forks source link

Incorrect parse of attribute value causes error #37

Closed faultyserver closed 6 years ago

faultyserver commented 6 years ago

Whenever the last attribute of a tag is not a string literal, it incorrectly includes the closing parenthesis as part of the attribute value. This causes the generated template code to have an extra closing parenthesis, and causes an "unexpected token: )" error:

a(href=Constants::TWITTER_URL) Contact Us
--------------------------------------------------------------------------------
Syntax error in expanded macro: macro_4472530688:191: unexpected token: )

__kilt_io__ << (Constants::TWITTER_URL)).to_s.gsub(/"/,"&quot;")

Adding a space after the attribute fixes the issue:

a(href=Constants::TWITTER_URL ) Contact Us

But it'd be nice to not have to have this extra space every time there's a dynamic value.

jeromegn commented 6 years ago

I believe I just fixed this. Mind trying master to make sure this is the case?