{"action":"created","comment":{"url":"https://api.github.com/repos/bem/bem-xjst/pulls/comments/24053856","id":24053856,"diff_hunk":"@@ -375,14 +397,57 @@ Compiler.prototype.flatten = function flatten(expr) {\n         callee: { type: 'Identifier', name: 'template' },\n         arguments: t.predicates\n       },\n-      arguments: [ this.replaceBody(t.body) ]\n+      arguments: [ this.replaceBody(t.body, extendedModeDetected) ]\n     };\n   }, this);\n };\n \n-Compiler.prototype.replaceBody = function replaceBody(body) {\n+Compiler.prototype.replaceBody = function replaceBody(body, extendedModeDetected) {\n   var self = this;\n \n+  // Desugar bodies of replace() and extend()\n+  if (extendedModeDetected) {\n+    body.body = estraverse.replace(body.body, {\n+      enter: function (ast, parent) {\n+        // don't mess with nested scopes\n+        if (ast.type === 'FunctionDeclaration' ||\n+            ast.type === 'FunctionExpression') {\n+          this.skip();\n+        }\n+      },\n+      leave: function (ast) {\n+        if (ast.type === 'ReturnStatement') {\n+          var applyCtxArgNode,\n+              applyCtxNode;\n+          if (extendedModeDetected === 'replace') {\n+            applyCtxArgNode = ast.argument;\n+          } else if (extendedModeDetected === 'extend') {\n+            applyCtxArgNode = {","path":"lib/bemhtml/compiler.js","position":97,"original_position":97,"commit_id":"da75737892d2584b794f4b6dbe2e20b5134b5142","original_commit_id":"da75737892d2584b794f4b6dbe2e20b5134b5142","user":{"login":"indutny","id":238531,"avatar_url":"https://avatars.githubusercontent.com/u/238531?v=3","gravatar_id":"","url":"https://api.github.com/users/indutny","html_url":"https://github.com/indutny","followers_url":"https://api.github.com/users/indutny/followers","following_url":"https://api.github.com/users/indutny/following{/other_user}","gists_url":"https://api.github.com/users/indutny/gists{/gist_id}","starred_url":"https://api.github.com/users/indutny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indutny/subscriptions","organizations_url":"https://api.github.com/users/indutny/orgs","repos_url":"https://api.github.com/users/indutny/repos","events_url":"https://api.github.com/users/indutny/events{/privacy}","received_events_url":"https://api.github.com/users/indutny/received_events","type":"User","site_admin":false},"body":"Style! :) Missing semicolon, odd braces alignment. Please keep it the same as it is in the rest of the file.","created_at":"2015-02-04T00:32:33Z","updated_at":"2015-02-04T00:32:33Z","html_url":"https://github.com/bem/bem-xjst/pull/24#discussion_r24053856","pull_request_url":"https://api.github.com/repos/bem/bem-xjst/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/comments/24053856"},"html":{"href":"https://github.com/bem/bem-xjst/pull/24#discussion_r24053856"},"pull_request":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/bem/bem-xjst/pulls/24","id":28105629,"html_url":"https://github.com/bem/bem-xjst/pull/24","diff_url":"https://github.com/bem/bem-xjst/pull/24.diff","patch_url":"https://github.com/bem/bem-xjst/pull/24.patch","issue_url":"https://api.github.com/repos/bem/bem-xjst/issues/24","number":24,"state":"open","locked":false,"title":"Extend feature","user":{"login":"vkz","id":917220,"avatar_url":"https://avatars.githubusercontent.com/u/917220?v=3","gravatar_id":"","url":"https://api.github.com/users/vkz","html_url":"https://github.com/vkz","followers_url":"https://api.github.com/users/vkz/followers","following_url":"https://api.github.com/users/vkz/following{/other_user}","gists_url":"https://api.github.com/users/vkz/gists{/gist_id}","starred_url":"https://api.github.com/users/vkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkz/subscriptions","organizations_url":"https://api.github.com/users/vkz/orgs","repos_url":"https://api.github.com/users/vkz/repos","events_url":"https://api.github.com/users/vkz/events{/privacy}","received_events_url":"https://api.github.com/users/vkz/received_events","type":"User","site_admin":false},"body":"extend() feature requested in #22 ","created_at":"2015-01-27T12:48:46Z","updated_at":"2015-02-04T00:32:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6dac82cebb03c9b49b5fd1ef33114d1e2e0531af","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bem/bem-xjst/pulls/24/commits","review_comments_url":"https://api.github.com/repos/bem/bem-xjst/pulls/24/comments","review_comment_url":"https://api.github.com/repos/bem/bem-xjst/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bem/bem-xjst/issues/24/comments","statuses_url":"https://api.github.com/repos/bem/bem-xjst/statuses/da75737892d2584b794f4b6dbe2e20b5134b5142","head":{"label":"vkz:extend-feature","ref":"extend-feature","sha":"da75737892d2584b794f4b6dbe2e20b5134b5142","user":{"login":"vkz","id":917220,"avatar_url":"https://avatars.githubusercontent.com/u/917220?v=3","gravatar_id":"","url":"https://api.github.com/users/vkz","html_url":"https://github.com/vkz","followers_url":"https://api.github.com/users/vkz/followers","following_url":"https://api.github.com/users/vkz/following{/other_user}","gists_url":"https://api.github.com/users/vkz/gists{/gist_id}","starred_url":"https://api.github.com/users/vkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkz/subscriptions","organizations_url":"https://api.github.com/users/vkz/orgs","repos_url":"https://api.github.com/users/vkz/repos","events_url":"https://api.github.com/users/vkz/events{/privacy}","received_events_url":"https://api.github.com/users/vkz/received_events","type":"User","site_admin":false},"repo":{"id":29905516,"name":"bem-xjst","full_name":"vkz/bem-xjst","owner":{"login":"vkz","id":917220,"avatar_url":"https://avatars.githubusercontent.com/u/917220?v=3","gravatar_id":"","url":"https://api.github.com/users/vkz","html_url":"https://github.com/vkz","followers_url":"https://api.github.com/users/vkz/followers","following_url":"https://api.github.com/users/vkz/following{/other_user}","gists_url":"https://api.github.com/users/vkz/gists{/gist_id}","starred_url":"https://api.github.com/users/vkz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkz/subscriptions","organizations_url":"https://api.github.com/users/vkz/orgs","repos_url":"https://api.github.com/users/vkz/repos","events_url":"https://api.github.com/users/vkz/events{/privacy}","received_events_url":"https://api.github.com/users/vkz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vkz/bem-xjst","description":"XJST Compiler extensions for BEM","fork":true,"url":"https://api.github.com/repos/vkz/bem-xjst","forks_url":"https://api.github.com/repos/vkz/bem-xjst/forks","keys_url":"https://api.github.com/repos/vkz/bem-xjst/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vkz/bem-xjst/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vkz/bem-xjst/teams","hooks_url":"https://api.github.com/repos/vkz/bem-xjst/hooks","issue_events_url":"https://api.github.com/repos/vkz/bem-xjst/issues/events{/number}","events_url":"https://api.github.com/repos/vkz/bem-xjst/events","assignees_url":"https://api.github.com/repos/vkz/bem-xjst/assignees{/user}","branches_url":"https://api.github.com/repos/vkz/bem-xjst/branches{/branch}","tags_url":"https://api.github.com/repos/vkz/bem-xjst/tags","blobs_url":"https://api.github.com/repos/vkz/bem-xjst/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vkz/bem-xjst/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vkz/bem-xjst/git/refs{/sha}","trees_url":"https://api.github.com/repos/vkz/bem-xjst/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vkz/bem-xjst/statuses/{sha}","languages_url":"https://api.github.com/repos/vkz/bem-xjst/languages","stargazers_url":"https://api.github.com/repos/vkz/bem-xjst/stargazers","contributors_url":"https://api.github.com/repos/vkz/bem-xjst/contributors","subscribers_url":"https://api.github.com/repos/vkz/bem-xjst/subscribers","subscription_url":"https://api.github.com/repos/vkz/bem-xjst/subscription","commits_url":"https://api.github.com/repos/vkz/bem-xjst/commits{/sha}","git_commits_url":"https://api.github.com/repos/vkz/bem-xjst/git/commits{/sha}","comments_url":"https://api.github.com/repos/vkz/bem-xjst/comments{/number}","issue_comment_url":"https://api.github.com/repos/vkz/bem-xjst/issues/comments/{number}","contents_url":"https://api.github.com/repos/vkz/bem-xjst/contents/{+path}","compare_url":"https://api.github.com/repos/vkz/bem-xjst/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vkz/bem-xjst/merges","archive_url":"https://api.github.com/repos/vkz/bem-xjst/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vkz/bem-xjst/downloads","issues_url":"https://api.github.com/repos/vkz/bem-xjst/issues{/number}","pulls_url":"https://api.github.com/repos/vkz/bem-xjst/pulls{/number}","milestones_url":"https://api.github.com/repos/vkz/bem-xjst/milestones{/number}","notifications_url":"https://api.github.com/repos/vkz/bem-xjst/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vkz/bem-xjst/labels{/name}","releases_url":"https://api.github.com/repos/vkz/bem-xjst/releases{/id}","created_at":"2015-01-27T08:53:56Z","updated_at":"2015-01-27T08:53:56Z","pushed_at":"2015-02-03T16:03:10Z","git_url":"git://github.com/vkz/bem-xjst.git","ssh_url":"git@github.com:vkz/bem-xjst.git","clone_url":"https://github.com/vkz/bem-xjst.git","svn_url":"https://github.com/vkz/bem-xjst","homepage":null,"size":191,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bem:master","ref":"master","sha":"1995df639e358ee1eb1ce60092ab9998a540bdf1","user":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"repo":{"id":10028367,"name":"bem-xjst","full_name":"bem/bem-xjst","owner":{"login":"bem","id":223412,"avatar_url":"https://avatars.githubusercontent.com/u/223412?v=3","gravatar_id":"","url":"https://api.github.com/users/bem","html_url":"https://github.com/bem","followers_url":"https://api.github.com/users/bem/followers","following_url":"https://api.github.com/users/bem/following{/other_user}","gists_url":"https://api.github.com/users/bem/gists{/gist_id}","starred_url":"https://api.github.com/users/bem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bem/subscriptions","organizations_url":"https://api.github.com/users/bem/orgs","repos_url":"https://api.github.com/users/bem/repos","events_url":"https://api.github.com/users/bem/events{/privacy}","received_events_url":"https://api.github.com/users/bem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bem/bem-xjst","description":"XJST Compiler extensions for BEM","fork":false,"url":"https://api.github.com/repos/bem/bem-xjst","forks_url":"https://api.github.com/repos/bem/bem-xjst/forks","keys_url":"https://api.github.com/repos/bem/bem-xjst/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bem/bem-xjst/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bem/bem-xjst/teams","hooks_url":"https://api.github.com/repos/bem/bem-xjst/hooks","issue_events_url":"https://api.github.com/repos/bem/bem-xjst/issues/events{/number}","events_url":"https://api.github.com/repos/bem/bem-xjst/events","assignees_url":"https://api.github.com/repos/bem/bem-xjst/assignees{/user}","branches_url":"https://api.github.com/repos/bem/bem-xjst/branches{/branch}","tags_url":"https://api.github.com/repos/bem/bem-xjst/tags","blobs_url":"https://api.github.com/repos/bem/bem-xjst/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bem/bem-xjst/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bem/bem-xjst/git/refs{/sha}","trees_url":"https://api.github.com/repos/bem/bem-xjst/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bem/bem-xjst/statuses/{sha}","languages_url":"https://api.github.com/repos/bem/bem-xjst/languages","stargazers_url":"https://api.github.com/repos/bem/bem-xjst/stargazers","contributors_url":"https://api.github.com/repos/bem/bem-xjst/contributors","subscribers_url":"https://api.github.com/repos/bem/bem-xjst/subscribers","subscription_url":"https://api.github.com/repos/bem/bem-xjst/subscription","commits_url":"https://api.github.com/repos/bem/bem-xjst/commits{/sha}","git_commits_url":"https://api.github.com/repos/bem/bem-xjst/git/commits{/sha}","comments_url":"https://api.github.com/repos/bem/bem-xjst/comments{/number}","issue_comment_url":"https://api.github.com/repos/bem/bem-xjst/issues/comments/{number}","contents_url":"https://api.github.com/repos/bem/bem-xjst/contents/{+path}","compare_url":"https://api.github.com/repos/bem/bem-xjst/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bem/bem-xjst/merges","archive_url":"https://api.github.com/repos/bem/bem-xjst/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bem/bem-xjst/downloads","issues_url":"https://api.github.com/repos/bem/bem-xjst/issues{/number}","pulls_url":"https://api.github.com/repos/bem/bem-xjst/pulls{/number}","milestones_url":"https://api.github.com/repos/bem/bem-xjst/milestones{/number}","notifications_url":"https://api.github.com/repos/bem/bem-xjst/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bem/bem-xjst/labels{/name}","releases_url":"https://api.github.com/repos/bem/bem-xjst/releases{/id}","created_at":"2013-05-13T09:22:05Z","updated_at":"2015-02-03T11:50:14Z","pushed_at":"2015-02-03T11:50:14Z","git_url":"git://github.com/bem/bem-xjst.git","ssh_url":"git@github.com:bem/bem-xjst.git","clone_url":"https://github.com/bem/bem-xjst.git","svn_url":"https://github.com/bem/bem-xjst","homepage":null,"size":649,"stargazers_count":6,"watchers_count":6,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":10,"forks":3,"open_issues":10,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/24"},"html":{"href":"https://github.com/bem/bem-xjst/pull/24"},"issue":{"href":"https://api.github.com/repos/bem/bem-xjst/issues/24"},"comments":{"href":"https://api.github.com/repos/bem/bem-xjst/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bem/bem-xjst/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/bem/bem-xjst/statuses/da75737892d2584b794f4b6dbe2e20b5134b5142"}}}}