GitHub PullRequestReviewCommentEvent at 2014-08-01 17:56:01
Repository: docs
Actor: ebidel
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Polymer/docs/pulls/comments/15709348","id":15709348,"diff_hunk":"@@ -265,3 +265,64 @@ You can also chain filters, passing the output of one filter to another:\n     {{myNumber | toHex | toUpperCase}}\n {% endraw %}\n \n+### Writing global filters\n+\n+\n+Although Polymer supports adding [custom filters](#custom-filters) to the element prototype,\n+you may want to register global filters which can be reused across multiple elements.\n+\n+This can be achieved by adding a custom filter to the prototype of the\n+`PolymerExpressions` object. \n+\n+#### Creating global filters\n+\n+Let's create a filter for transforming the letters in any templated string\n+to uppercase. Once registered, we will be able to use it as follows:\n+\n+{% raw %}\n+    {{Hello Polymer | uppercase}}\n+{% endraw %}\n+\n+To register `uppercase` as a global filter, we add it to the `PolymerExpressions`\n+object and define our filter as a function which operates on the `input` supplied.\n+In this case the input is the string `\"Hello Polymer\"`. Our final filter is:\n+\n+{% raw %}\n+    PolymerExpressions.prototype.uppercase = function(input){\n+      return input.toUpperCase();\n+    };\n+{% endraw %}\n+\n+Earlier we mentioned you can pass parameters to a filter. This is similarly\n+supported for global filters. One example is a `startsWith` filter that could\n+return only those items in an array that begin with a certain letter:\n+\n+{% raw %}\n+    {{arrayOfFriends | startsWith('M')}}\n+{% endraw %}\n+\n+The `letter` parameter (and any other parameters we wish to specify) can be defined\n+after the initial input as used as you would in any normal function:\n+\n+{% raw %}\n+    PolymerExpressions.prototype.startsWith = function (input, letter) {\n+        return input.filter(function(item){\n+        \treturn item[0] === letter;\n+        });\n+    };\n+{% endraw %}\n+\n+A community-driven [collection](https://github.com/addyosmani/polymer-filters) of Polymer filters is available if you require further","path":"docs/polymer/expressions.md","position":152,"original_position":152,"commit_id":"d02f2631ac5336db0a5c6622f06beb654e7904bf","original_commit_id":"d02f2631ac5336db0a5c6622f06beb654e7904bf","user":{"login":"ebidel","id":238208,"avatar_url":"https://avatars.githubusercontent.com/u/238208?v=1","gravatar_id":"e7948aac7c52b26470be80311873a398","url":"https://api.github.com/users/ebidel","html_url":"https://github.com/ebidel","followers_url":"https://api.github.com/users/ebidel/followers","following_url":"https://api.github.com/users/ebidel/following{/other_user}","gists_url":"https://api.github.com/users/ebidel/gists{/gist_id}","starred_url":"https://api.github.com/users/ebidel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebidel/subscriptions","organizations_url":"https://api.github.com/users/ebidel/orgs","repos_url":"https://api.github.com/users/ebidel/repos","events_url":"https://api.github.com/users/ebidel/events{/privacy}","received_events_url":"https://api.github.com/users/ebidel/received_events","type":"User","site_admin":false},"body":"A useful set of community-driven....\r\n\r\nif you require -> if you need further examples of global filters.","created_at":"2014-08-01T17:56:01Z","updated_at":"2014-08-01T17:56:01Z","html_url":"https://github.com/Polymer/docs/pull/573#discussion_r15709348","pull_request_url":"https://api.github.com/repos/Polymer/docs/pulls/573","_links":{"self":{"href":"https://api.github.com/repos/Polymer/docs/pulls/comments/15709348"},"html":{"href":"https://github.com/Polymer/docs/pull/573#discussion_r15709348"},"pull_request":{"href":"https://api.github.com/repos/Polymer/docs/pulls/573"}}},"pull_request":{"url":"https://api.github.com/repos/Polymer/docs/pulls/573","id":19208601,"html_url":"https://github.com/Polymer/docs/pull/573","diff_url":"https://github.com/Polymer/docs/pull/573.diff","patch_url":"https://github.com/Polymer/docs/pull/573.patch","issue_url":"https://api.github.com/repos/Polymer/docs/issues/573","number":573,"state":"open","title":"Adds global filters docs for #571","user":{"login":"addyosmani","id":110953,"avatar_url":"https://avatars.githubusercontent.com/u/110953?v=1","gravatar_id":"96270e4c3e5e9806cf7245475c00b275","url":"https://api.github.com/users/addyosmani","html_url":"https://github.com/addyosmani","followers_url":"https://api.github.com/users/addyosmani/followers","following_url":"https://api.github.com/users/addyosmani/following{/other_user}","gists_url":"https://api.github.com/users/addyosmani/gists{/gist_id}","starred_url":"https://api.github.com/users/addyosmani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/addyosmani/subscriptions","organizations_url":"https://api.github.com/users/addyosmani/orgs","repos_url":"https://api.github.com/users/addyosmani/repos","events_url":"https://api.github.com/users/addyosmani/events{/privacy}","received_events_url":"https://api.github.com/users/addyosmani/received_events","type":"User","site_admin":false},"body":"reviewer: @ebidel ","created_at":"2014-08-01T13:00:02Z","updated_at":"2014-08-01T17:56:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0ca7f84124a89bcab64159aacd78766b46478b73","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Polymer/docs/pulls/573/commits","review_comments_url":"https://api.github.com/repos/Polymer/docs/pulls/573/comments","review_comment_url":"https://api.github.com/repos/Polymer/docs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Polymer/docs/issues/573/comments","statuses_url":"https://api.github.com/repos/Polymer/docs/statuses/d02f2631ac5336db0a5c6622f06beb654e7904bf","head":{"label":"Polymer:globalfilters","ref":"globalfilters","sha":"d02f2631ac5336db0a5c6622f06beb654e7904bf","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=1","gravatar_id":"a08da340b07b06a9cc2c107a98c8623f","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":7804910,"name":"docs","full_name":"Polymer/docs","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=1","gravatar_id":"a08da340b07b06a9cc2c107a98c8623f","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/docs","description":"Documentation for Polymer","fork":false,"url":"https://api.github.com/repos/Polymer/docs","forks_url":"https://api.github.com/repos/Polymer/docs/forks","keys_url":"https://api.github.com/repos/Polymer/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/docs/teams","hooks_url":"https://api.github.com/repos/Polymer/docs/hooks","issue_events_url":"https://api.github.com/repos/Polymer/docs/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/docs/events","assignees_url":"https://api.github.com/repos/Polymer/docs/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/docs/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/docs/tags","blobs_url":"https://api.github.com/repos/Polymer/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/docs/languages","stargazers_url":"https://api.github.com/repos/Polymer/docs/stargazers","contributors_url":"https://api.github.com/repos/Polymer/docs/contributors","subscribers_url":"https://api.github.com/repos/Polymer/docs/subscribers","subscription_url":"https://api.github.com/repos/Polymer/docs/subscription","commits_url":"https://api.github.com/repos/Polymer/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/docs/issues/comments/{number}","contents_url":"https://api.github.com/repos/Polymer/docs/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/docs/merges","archive_url":"https://api.github.com/repos/Polymer/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/docs/downloads","issues_url":"https://api.github.com/repos/Polymer/docs/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/docs/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/docs/releases{/id}","created_at":"2013-01-24T19:11:00Z","updated_at":"2014-08-01T14:29:15Z","pushed_at":"2014-08-01T12:57:40Z","git_url":"git://github.com/Polymer/docs.git","ssh_url":"git@github.com:Polymer/docs.git","clone_url":"https://github.com/Polymer/docs.git","svn_url":"https://github.com/Polymer/docs","homepage":"www.polymer-project.org","size":23274,"stargazers_count":369,"watchers_count":369,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":574,"mirror_url":null,"open_issues_count":85,"forks":574,"open_issues":85,"watchers":369,"default_branch":"master"}},"base":{"label":"Polymer:master","ref":"master","sha":"6de6398a31afd411cd36b96117db920905f691ea","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=1","gravatar_id":"a08da340b07b06a9cc2c107a98c8623f","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":7804910,"name":"docs","full_name":"Polymer/docs","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=1","gravatar_id":"a08da340b07b06a9cc2c107a98c8623f","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/docs","description":"Documentation for Polymer","fork":false,"url":"https://api.github.com/repos/Polymer/docs","forks_url":"https://api.github.com/repos/Polymer/docs/forks","keys_url":"https://api.github.com/repos/Polymer/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/docs/teams","hooks_url":"https://api.github.com/repos/Polymer/docs/hooks","issue_events_url":"https://api.github.com/repos/Polymer/docs/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/docs/events","assignees_url":"https://api.github.com/repos/Polymer/docs/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/docs/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/docs/tags","blobs_url":"https://api.github.com/repos/Polymer/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/docs/languages","stargazers_url":"https://api.github.com/repos/Polymer/docs/stargazers","contributors_url":"https://api.github.com/repos/Polymer/docs/contributors","subscribers_url":"https://api.github.com/repos/Polymer/docs/subscribers","subscription_url":"https://api.github.com/repos/Polymer/docs/subscription","commits_url":"https://api.github.com/repos/Polymer/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/docs/issues/comments/{number}","contents_url":"https://api.github.com/repos/Polymer/docs/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/docs/merges","archive_url":"https://api.github.com/repos/Polymer/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/docs/downloads","issues_url":"https://api.github.com/repos/Polymer/docs/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/docs/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/docs/releases{/id}","created_at":"2013-01-24T19:11:00Z","updated_at":"2014-08-01T14:29:15Z","pushed_at":"2014-08-01T12:57:40Z","git_url":"git://github.com/Polymer/docs.git","ssh_url":"git@github.com:Polymer/docs.git","clone_url":"https://github.com/Polymer/docs.git","svn_url":"https://github.com/Polymer/docs","homepage":"www.polymer-project.org","size":23274,"stargazers_count":369,"watchers_count":369,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":574,"mirror_url":null,"open_issues_count":85,"forks":574,"open_issues":85,"watchers":369,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polymer/docs/pulls/573"},"html":{"href":"https://github.com/Polymer/docs/pull/573"},"issue":{"href":"https://api.github.com/repos/Polymer/docs/issues/573"},"comments":{"href":"https://api.github.com/repos/Polymer/docs/issues/573/comments"},"review_comments":{"href":"https://api.github.com/repos/Polymer/docs/pulls/573/comments"},"review_comment":{"href":"https://api.github.com/repos/Polymer/docs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Polymer/docs/pulls/573/commits"},"statuses":{"href":"https://api.github.com/repos/Polymer/docs/statuses/d02f2631ac5336db0a5c6622f06beb654e7904bf"}}}}