Git Product home page Git Product logo

Comments (4)

eygraber avatar eygraber commented on July 3, 2024

Actually it looks like it goes a little deeper than what I said above. The parameters to functions don't get replaced recursively.

- location: something/$uid
  read: canDoSomething($uid, '1')

functions:
  - canDoSomething(uid, one):      auth.uid === uid && canDoSomethingElse(one)
  - canDoSomethingElse(uid): root.some.path[uid].exists()

outputs:

auth.$uid === $uid && root.child('some').child('path').child($uid).exists()

So I pass one to canDoSomethingElse but since its parameter is named uid it uses uid from canDoSomething which resolves to $uid instead of '1'

from blaze_compiler.

mckoss avatar mckoss commented on July 3, 2024

FYI - I've just started work on a Blaze alternative and ran your example through the new Bolt language:

path /something/$uid {
     read() { return canDoSomething($uid, '1'); }
}

function canDoSomething(uid, one) { return auth.uid === uid && canDoSomethingElse(one); }

function canDoSomethingElse(uid) { return root.some.path[uid].exists(); }

results in:

{
  "rules": {
    "something": {
      "$uid": {
        ".read": "auth.uid == $uid && root.child('some').child('path').child('1').exists()"
      }
    }
  }
}

Bolt is in early Alpha now - but I'd love you feedback on it, since you've been using Blaze.

from blaze_compiler.

eygraber avatar eygraber commented on July 3, 2024

Awesome! I'll definitely try that out when I get a chance.

from blaze_compiler.

tomlarkworthy avatar tomlarkworthy commented on July 3, 2024

Yeah there are some bugs still in the parameter sanitation, the short term fix is to avoid reuse of variable names.

from blaze_compiler.

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.