Skip to content

Conversation

janschoenherr
Copy link

I would like to propose a change to the filter token regex. This will allow for object definitions to be passed as a single argument to the filter. This will only work for shallow objects. For deep objects we would have to use a better parser.

e.g.:

{{ '%count% Pull Requests' | trans {count: count} }}

currently it works without spaces only:

{{ '%count% Pull Requests' | trans {count:count} }}

I would like to propose a change to the filter token regex. This will allow for object definitions to be passed as a single argument to the filter. This will only work for shallow objects. For deep objects we would have to use a better parser.

e.g.:

{{ '%count% Pull Requests' | trans {count: count} }}

currently only this works:

{{ '%count% Pull Requests' | trans {count:count} }}
@yyx990803
Copy link
Member

How would the filter implementation work in this case? Do you JSON.parse the thing?

@janschoenherr
Copy link
Author

In the custom filter 'trans' , currently I am using the Vue expression parser to evaluate the expression.

That way {count:count} will actually evaluate to a hash like {count: 3}, which is then passed to the translation function.

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

Successfully merging this pull request may close these issues.

2 participants