-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
root context bleeds into compiled function parameters #269
Comments
I'd say it's better to use a computed block for this.
|
Ah, yes. Hadn't anticipated function expressions inside tags. It could be made to work — would need to do an initial pass on the code to annotate it with scopes so that we can identify that The much simpler alternative would be to disallow [arrow] function expressions in tags. That would have a theoretical performance benefit (the mapping function would only need to be created once), though it does mean you would need to add a computed property as per @neoel's example, or add a helper: {{#each cats.filter(notMaru) as cat}}
<!-- ... -->
{{/each}}
<script>
export default {
helpers: {
notMaru: cat => cat.name !== 'Maru'
}
};
</script> Not totally sure which is the best option! |
@Rich-Harris I think it'd be worth to add support for it, but adding it as a helper seems to be the best option for performance + reusability. |
allow [arrow] function expressions inside tags
This is fixed in 1.9.1 — thanks |
REPL
{{#each cats.filter(function(c) { return c.name!='Maru' }) as cat}}
compiles to
root.cats.filter(function(root.c) {return root.c.name!='Maru'}
The text was updated successfully, but these errors were encountered: