{"action":"created","issue":{"url":"https://api.github.com/repos/vuejs/vue/issues/2756","repository_url":"https://api.github.com/repos/vuejs/vue","labels_url":"https://api.github.com/repos/vuejs/vue/issues/2756/labels{/name}","comments_url":"https://api.github.com/repos/vuejs/vue/issues/2756/comments","events_url":"https://api.github.com/repos/vuejs/vue/issues/2756/events","html_url":"https://github.com/vuejs/vue/issues/2756","id":151557492,"number":2756,"title":"[Suggestion] Vue 2.0 - Bring back filters please","user":{"login":"smolinari","id":3314957,"avatar_url":"https://avatars.githubusercontent.com/u/3314957?v=3","gravatar_id":"","url":"https://api.github.com/users/smolinari","html_url":"https://github.com/smolinari","followers_url":"https://api.github.com/users/smolinari/followers","following_url":"https://api.github.com/users/smolinari/following{/other_user}","gists_url":"https://api.github.com/users/smolinari/gists{/gist_id}","starred_url":"https://api.github.com/users/smolinari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolinari/subscriptions","organizations_url":"https://api.github.com/users/smolinari/orgs","repos_url":"https://api.github.com/users/smolinari/repos","events_url":"https://api.github.com/users/smolinari/events{/privacy}","received_events_url":"https://api.github.com/users/smolinari/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vuejs/vue/labels/2.0","name":"2.0","color":"d93f0b"},{"url":"https://api.github.com/repos/vuejs/vue/labels/discussion","name":"discussion","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":38,"created_at":"2016-04-28T06:14:42Z","updated_at":"2016-04-29T06:06:03Z","closed_at":null,"body":"Hi,\r\n\r\nThere was a hot discussion in the Gitter chat and there is [a nice post on the forum](http://forum.vuejs.org/topic/3896/i-m-going-to-miss-filters-in-vue-2-0) about people missing the `filter` feature in 2.0 and it actually being a no-go to upgrading for some. This isn't a positive direction for the community it seems.  \r\n\r\nSo, I'd like to put up this suggestion to bring back filters in 2.0, because they are so loved and, I would agree, smart. Here are some of the arguments for filters (gathered from the different discussions and no guarantee for correctness):\r\n\r\n- They are easier to read in the templates \r\n\r\n`thing in things | filterBy 'foo' | orderBy 'bar' | limitBy 5`\r\n\r\nis simply easy to read. In other words, chaining filters helps make sense of what should actually be expected.\r\n\r\n- Filters are global, which is great in a templating/ view system. Currency is a simple example of a great filter that can be used everywhere, just by calling it.\r\n\r\n- Without filters, there will be a ton of boilerplate.\r\n\r\n- Filters allow noobs to learn faster and get a quick and nice winning experience with Vue.\r\n\r\n- Using a mixin for every component to include a self-made \"filter\" isn't really feasible. \r\n\r\nNeedless to say, there are probably strong arguments for removing filter from an engineering perspective and why I would suggest this thread be a pros and cons and voting for or against the return of filters.\r\n\r\nScott"},"comment":{"url":"https://api.github.com/repos/vuejs/vue/issues/comments/215633620","html_url":"https://github.com/vuejs/vue/issues/2756#issuecomment-215633620","issue_url":"https://api.github.com/repos/vuejs/vue/issues/2756","id":215633620,"user":{"login":"smolinari","id":3314957,"avatar_url":"https://avatars.githubusercontent.com/u/3314957?v=3","gravatar_id":"","url":"https://api.github.com/users/smolinari","html_url":"https://github.com/smolinari","followers_url":"https://api.github.com/users/smolinari/followers","following_url":"https://api.github.com/users/smolinari/following{/other_user}","gists_url":"https://api.github.com/users/smolinari/gists{/gist_id}","starred_url":"https://api.github.com/users/smolinari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolinari/subscriptions","organizations_url":"https://api.github.com/users/smolinari/orgs","repos_url":"https://api.github.com/users/smolinari/repos","events_url":"https://api.github.com/users/smolinari/events{/privacy}","received_events_url":"https://api.github.com/users/smolinari/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T06:06:03Z","updated_at":"2016-04-29T06:06:03Z","body":"@yyx990803 - Your example exemplifies the issue, I think. Again, I'm not the best JS programmer, but I don't need to be a JS programmer to know `filteredThings` says nothing about what it really does.\r\n\r\nSo, ok. we could have a method name like `filterByOrderByAndLimit'. What about the arguments? \r\n\r\n`<div v-for=\"filterByOrderByAndLimit(things,thing,'foo','bar',5)\">`\r\n\r\nWould that be correct?\r\n\r\nIf it is, that might be feasible. Still, it doesn't look good. \r\n\r\nAnd, now I want only filterBy and OrderBy. Do I need a separate method to do that too? And then I want to add currency formatting. Another method? The filter chaining in the templates makes manipulating the presentation flexible and very expressive. This concern has yet to be properly addressed with methods (and my lack of knowledge isn't allowing me to understand methods can be better). \r\n\r\nCan this be possible?\r\n\r\n`<div v-for=\"filterBy(things, thing, 'foo').OrderBy('bar').Limit(5)\">` \r\n\r\nI agree that doing too much logic in a template is something to avoid. But, filter chaining and the ability to simply pop in a filter anywhere in an app's components/ templates is a fantastic concept and there was a reason why you added it to begin with. What was that reason or reasons? If you can name them, then I will bet money they outweigh \"but it promotes bad practices\" by a mile. \r\n\r\nAnything that allows flexibility can be used improperly, just like Vue itself. The main argument for `inline-template` was it was flexible and allowed Vue to be used in different ways. Filters isn't much different, other than it is Vue internal and doesn't affect how Vue might be used externally. Still, that doesn't devalue its importance. Remember, a lot of people have also said this would be a no-go for them to upgrade. It is that important! :smile.\r\n\r\nThe new way just needs the same attributes the old way had. \r\n\r\n- chainable\r\n- global\r\n- add to templates to expressiveness in  how the data in the templates will be manipulated\r\n\r\n(did I forget anything?)\r\n\r\nIf it can do all that, then I am sure everyone will be pretty much satisfied. I personally can't see it happening with methods (yet).\r\n\r\nScott"}}