Git Product home page Git Product logo

Comments (3)

sds avatar sds commented on June 16, 2024

I don't know if writing code this way always does what you want, and I would advise against it. I think haml-lint is actually doing the right thing here given the quick investigation I've done.

Consider the following code:

- if false ||
-    true
  Wheee!
- else
  Something else!

The above code fails to compile when run via haml itself:

haml test.haml
Syntax error on line 4: Got "else" with no preceding "if"

Why this works without the else is beyond the time I have to spare for this right now.

Just to drive the point home, consider another example:

= 1 +
= 2

Given your example above this should work, but it fails to compile. Spanning scripts across multiple lines doesn't do what you expect.

This does suggest we should add a linter for this situation, however. :)

from haml-lint.

himdel avatar himdel commented on June 16, 2024

Hi, I actually noticed the else problem with haml, and I obviously agree with your = 1 + counter-example, it's just that .. well, sometimes you really want to be able to do a multiline if, and the | haml operator doesn't seem to do the trick. But oh well, what can you do, back to rewriting.. :) I guess something like - tmp ||= subcondition might do the trick.

I do agree that there should be a linter since this is apparently not supported nor even mentioned in haml docs. Also, please note that code like - if foo || without any subsequent - line passes haml-lint checks as well.

from haml-lint.

sds avatar sds commented on June 16, 2024

Quickly whipped together a solution that will probably catch most cases in 11ca42a.

from haml-lint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.