Git Product home page Git Product logo

Comments (5)

MaxLap avatar MaxLap commented on September 25, 2024 1

So thanks for the report. Unfortunately, I would say the problem is in your code.

From my testing, this (your code) is not valid ruby code:

render 'devise/shared/error_messages', resource:
f.hidden_field :reset_password_token

Try it in a file and try to run rubocop or even just plain ruby on it. Same error.

Or try it in an irb console (with a def, so that it's all treated at once):

def foo
  render 'devise/shared/error_messages', resource:
  f.hidden_field :reset_password_token
end

It will get refused. The code might work in HAML, and in the previous version of haml-lint. But that's just an unintended side-effect of how the code is processed (HAML adds lots of parentheses and HAML-lint used to process line by line).

It feels weird to use the shortcut of not specifying a variable without having parentheses around the call. It really feels ambiguous if the result of the next line should be used or the default variable. And this error is proof that it's ambiguous.

Your solution is to put parentheses: render('devise/shared/error_messages', resource:)

Regards,

from haml-lint.

sds avatar sds commented on September 25, 2024

Are you sure resource: has no arguments after it? What is the expected behavior when the value is omitted? Treat as nil?

from haml-lint.

MaxLap avatar MaxLap commented on September 25, 2024

It's a shortcut to using the variable/method with the same name. Like in JS.

I forgot this issue. I'm looking into it now.

from haml-lint.

sds avatar sds commented on September 25, 2024

Going to close as a question that has been answered. Thanks!

from haml-lint.

linxola avatar linxola commented on September 25, 2024

@MaxLap Thank you for such a detailed answer and the solution to my problem.
You're right, it's really feeling a bit weird to use such shorthand syntax without parentheses. Somehow I didn't ponder over it before...

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.