Skip to content

Allow white spaces inside object literal. #3214

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

Closed
wants to merge 3 commits into from
Closed

Allow white spaces inside object literal. #3214

wants to merge 3 commits into from

Conversation

zigomir
Copy link
Contributor

@zigomir zigomir commented Jul 3, 2016

Fix for #3210.

@posva
Copy link
Member

posva commented Jul 3, 2016

LGTM. I guess it's worth mentioning in the docs

@kazupon
Copy link
Member

kazupon commented Jul 3, 2016

LGTM

@yyx990803
Copy link
Member

yyx990803 commented Jul 3, 2016

pure regex based approach is a somewhat incomplete fix. For example it would fail for this:

abc | filter {a:1} {b:2}

It would match {a:1} {b:2} as a single argument.

Additionally, if we support spaces inside object braces, they should probably work for arrays too:

abc | filter [1, { a: 2 }]

So we either support the full syntax, or not support it at all. A more proper parsing logic would have to do something similar to what the directive parser is doing: keeping track of braces/brackets/quotes state and only delimit an argument if we are not in any pairs.

@yyx990803
Copy link
Member

Fortunately in 2.0 we don't have this issue :o

@posva
Copy link
Member

posva commented Jul 3, 2016

So maybe we should just drop it and recommend to pass a computed property instead?

@zigomir
Copy link
Contributor Author

zigomir commented Jul 4, 2016

@yyx990803 I agree. This isn't proper fix then. I'll see what I can do about it :)

@zigomir
Copy link
Contributor Author

zigomir commented Jul 11, 2016

@yyx990803 I was playing around a bit more and come up with new syntax when filter has multiple arguments. If there are more filters they need to be wrapped in [] as you can see in spec. I'm not sure if this is the way we want to do it...especially with eval used 😊 .

This also forces us to document this behavior and update the docs/guide. I can do it, if this is the way we want to handle this, otherwise I think it's better we just document you should extract filters to functions or use no spaces like @posva already mentioned :)

@posva
Copy link
Member

posva commented Aug 19, 2016

We forgot about this. I'll rather keep it the way it is and add some documentation that adding a new syntax to filters which already use a special (non-js) syntax

@posva
Copy link
Member

posva commented Sep 23, 2016

Can this be closed now? I haven't followed well enough @zigomir

@zigomir
Copy link
Contributor Author

zigomir commented Sep 23, 2016

Yeah, for sure, it was just a silly attempt of mine :)

@zigomir zigomir closed this Sep 23, 2016
@zigomir zigomir deleted the fix-filter-parsing-3210 branch September 23, 2016 15:43
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.

4 participants