Skip to content
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

Named arguments are passed to filter as undefined #113

Closed
stewartknapman opened this issue Mar 4, 2019 · 2 comments
Closed

Named arguments are passed to filter as undefined #113

stewartknapman opened this issue Mar 4, 2019 · 2 comments
Labels

Comments

@stewartknapman
Copy link

Passing named arguments to a filter no longer works, arguments are given but they are all undefined.
It was previously working in version 4.0.0 and I have since upgraded to 7.4.0.

Example:

engine.registerFilter('t', function () {
  console.log(arguments);
})
{{ 'filter.arg.test.1' | t }}
// => Arguments ["filter.arg.test.1", callee: ƒ, Symbol(Symbol.iterator): ƒ]

{{ 'filter.arg.test.2' | t: 'foo', 'bar', 'baz' }}
// => Arguments(4) ["filter.arg.test.2", "foo", "bar", "baz", callee: ƒ, Symbol(Symbol.iterator): ƒ]

{{ 'filter.arg.test.3' | t: arg1: 'foo', arg2: 'bar', arg3: 'baz' }}
// => Arguments(4) ["filter.arg.test.3", undefined, undefined, undefined, callee: ƒ, Symbol(Symbol.iterator): ƒ]

In the v4.0.0 {{ 'filter.arg.test.3' | t: arg1: 'foo', arg2: 'bar', arg3: 'baz' }} would return the key and value for each argument as seperate arguments. This was fine, I just looped through them and paired them back up. But I wonder if it would be more helpful to return each of them as an object?

@harttle harttle added the bug label Mar 5, 2019
harttle pushed a commit that referenced this issue Mar 5, 2019
## [7.5.1](v7.5.0...v7.5.1) (2019-03-05)

### Bug Fixes

* named params for filters, working on [#113](#113) ([5ffc904](5ffc904))
@harttle
Copy link
Owner

harttle commented Mar 5, 2019

That's a mistake during the TypesScript refactor. Now I make them work again, but slightly different:

  1. Arguments with names now appears as a subarray rather than flattened.
  2. Argument key is no longer wrapped with single quotes.

See this integration test for details.

Any problems please let me know :)

@stewartknapman
Copy link
Author

@harttle That is magic! It all looks to be working as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants