-
Notifications
You must be signed in to change notification settings - Fork 109
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
Attribute parsing fails #81
Comments
I encourage you to send a pull request with support for |
I'm kind of undecided at how to address this problem. Could you give me some advice on this? My changes will affect the function Another idea is to replace the What do you think about these two approaches? |
Using regex is very tricky -- is it valid to have '=>' in an attribute? Hmm, I don't think so, but would have to check. If we are sure that '=>' is invalid as an attribute, then the regex solution might be the clearest path forward. The single-character no-lookahead nature of the attrib parser is one of the reasons that I didn't implement this in the past =/ a way to peak and auto-advance would be welcome, but more work. |
|
So the regex way seems like it isn't viable, then :( |
Further to the above: %a{ng_href: "#"} a message //1
%a{data: {ng_href: "#"}} a message //2
%a{data: {ng-href: "#"}} a message //3
%a{'ng-href': ""} a message //4 All of the above syntaxes fail to compile and cause the compiler to barf!. The only way to write the above such that it compiles to the desired output is %a{ng-href: "#"} a message
- or -
%a{data-ng-href: "#"} a message even though it is invalid syntax. Any chance this could be fixed soon? Be a very big help. Kind regards PS: Haml-JS is used in grunt-haml I'd also recommend the use of : in place of => as => has been deprecated in ruby 1.9+ |
Since the solution seems to be quite time expensive (writing a look ahead parser), I cannot do it in the scope of our project. Sorry. 😢 Googling for a possible improvement for the parser, I found http://pegjs.majda.cz/. You define a language grammar (similar to the Backus-Naur form) and the library will generate a parser library in javascript. The HAML source will be the input for the parser, the output will be in the form you specified in the language grammar. This means that we would already have a tokenizer. The parser would have to be rewritten to interpret the output of the tokenizer which is significantly simpler to do than to parse the HAML source directly. Also adding a feature like the one described here would only be a change in the language grammar 😄 @ablohowiak-fanhattan what do you think of such a change? I implemented a simple work around for my problem. I replace all occurrences of the |
This is concerning. I am curious whether any progress has been made here. |
I'm trying to translate a HAML template to HTML. The template looks as like this:
According to the HAML reference I expect it to be translated to:
But haml-js always ignored the
data-abc
part. I couldn't figure out why until I dug deeper into the code and discovered that my HAML syntax was wrong. It should have been:(notice the : instead of =>)
Why does haml-js ignore the
=>
-Syntax? The reference clearly states that it is part of HAML.The text was updated successfully, but these errors were encountered: