El 3/3/2008, a las 10:05, neem escribió: > Thank you for the explanation! > > In my opinion, to improve the haml comments should be possible at any > place, anyway they are removed. > When interpretator sees -#, it should remove the line. Probably, I am > mistaking and can't see the problems, that could appear in this case. > > Another problem. When I put the code like this: > - if > -# comment > - else > there is a translation into > if > end > # comment > else (but why I don't receive a notification about error?, can it > happen that block of code begins with "else" without "if" before?)
I know this may seem like a limitation (lack of flexibility as to where you can put your comments) but it's actually a strength of Haml. One of the reasons why Haml markup looks so clean is that it uses indentation to communicate semantics, just like Python does. So the benefit you get is auto-closing scopes and no need to worry about explicitly writing "end" all the time, and the cost is that you have to be disciplined about your use of whitespace. In other words, the rule is "indentation matters"; I think introducing exceptions to the indentation rules would reduce the simplicity and elegance of the rule, because it would become "indentation matters, uh, except for when..." In the example you originally posted you wrote: -if blah -# foo -else blah -end But you've broken the indentation rule right there, so to fix them you'd write: -if blah -# foo -else blah -end Which obviously reduces the visually continuity of the "foo" comment and the part of the code that it applies to, so where should the comment go? -if blah -else -# foo blah -end That's the spot for it, as it respects the indentation rule and its location clearly shows the block of code that it applies to. Cheers, Wincent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Haml" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/haml?hl=en -~----------~----~----~----~------~----~------~--~---
