-
Notifications
You must be signed in to change notification settings - Fork 16
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
Proposal: inline let #7
Comments
I'm curious about scoping. What happens if I say: {{let num 0}}
num = {{num}}
{{#each (list 1 2 3) as |num|}}
num = {{num}}
{{/each}}
num = {{num}} I'd expect to see:
Would it also work with explicit let's in block scope? {{let num 0}}
num = {{num}}
{{#each (list 1 2 3) as |int|}}
{{let num int}}
num = {{num}}
{{/each}}
num = {{num}} |
It does not do anything to resolve the path. It will only effect the path that's passed to it. This will be a good thing to verify with tests. I'll add these to confirm my assumptions. |
Any thoughts about multiple binding expressions as per {{let height (subtract top bottom) width (subtract right left)}} |
This is probably a better link for binding in Scheme http://docs.racket-lang.org/guide/let.html |
Multiple binding expressions seem like a great idea and should be easy to implement. Unfortunately, when one value changes, all of the binding vales will be reapplied but that might not be a problem considering that glimmer is smart about caching the updates. |
The scoping test was successful. Got exactly what you(and I) expected.
No, this actually seems to cause an infinite loop. Ember throws a warning that |
@cowboyd just added multiple declarations support |
I need to provide feedback in case the user messed up the order and specified value where path should be. |
One question: for multiple binding assignments, are previous binding expressions visible in subsequent ones? E.g. {{#let height (subtract top bottom) width (subtract right left) area (multiply height width)}} Not sure if it should or shouldn't be, or even what's possible, but I think it's important to ascertain which one it is. |
@cowboyd it does allow to be used in consequent assignments. I have a test for this scenario |
I haven't tried anything as collect as your example but I can try in an integration test |
*complex |
I had an idea recently of how we could create an inline version of
let
helper that'd automatically update a variable when calculation changes.For example,
Would output "world".
This value would also be reactive, so it'll automatically update the variable binding when calculation changes.
Would output "hello " first, on click of button would set
to
to "world" and render "hello world".I can be useful to define variables that apply to the entire template without introducing nesting and to define reactive variables that change based on computation.
The text was updated successfully, but these errors were encountered: