{"action":"created","comment":{"url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/comments/91866020","pull_request_review_id":12375471,"id":91866020,"diff_hunk":"@@ -0,0 +1,92 @@\n+//\n+// GenumKit\n+// Copyright (c) 2016 Olivier Halligon\n+// MIT Licence\n+//\n+\n+import Stencil\n+\n+struct CallableBlock {\n+  let parameters: [String]\n+  let nodes: [NodeType]\n+\n+  func context(_ context: Context, arguments: [Variable]) throws -> [String: Any] {\n+    var result = [String: Any]()\n+\n+    for (parameter, argument) in zip(parameters, arguments) {\n+      result[parameter] = try argument.resolve(context)\n+    }\n+\n+    return result\n+  }\n+}\n+\n+open class DefineNode: NodeType {\n+  open let variableName: String\n+  open let parameters: [String]\n+  open let nodes: [NodeType]\n+\n+  open class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {\n+    let components = token.components()\n+    guard components.count >= 2 else {\n+      throw TemplateSyntaxError(\"'define' tag takes at least one argument, the name of the variable to set\")\n+    }\n+    let variable = components[1]\n+    let parameters = Array(components.dropFirst(2))\n+\n+    let setNodes = try parser.parse(until([\"enddefine\"]))\n+    guard parser.nextToken() != nil else {\n+      throw TemplateSyntaxError(\"`enddefine` was not found.\")\n+    }\n+\n+    return DefineNode(variableName: variable, parameters: parameters, nodes: setNodes)\n+  }\n+\n+  public init(variableName: String, parameters: [String], nodes: [NodeType]) {\n+    self.variableName = variableName\n+    self.parameters = parameters\n+    self.nodes = nodes\n+  }\n+\n+  open func render(_ context: Context) throws -> String {\n+    let result = CallableBlock(parameters: parameters, nodes: nodes)\n+    context[variableName] = result","path":"GenumKit/Stencil/CallNode.swift","position":53,"original_position":53,"commit_id":"05a2e12a128797aa63ac035af57582587c44fa90","original_commit_id":"f3af1589837002c1be2412d3cc2d1a7538d30c32","user":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars.githubusercontent.com/u/216089?v=3","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"body":"Do you think we should keep it that way or would it be better to fail for `enumBlock` and render the `enumBlock2`?","created_at":"2016-12-11T21:35:05Z","updated_at":"2016-12-11T21:35:05Z","html_url":"https://github.com/AliSoftware/SwiftGen/pull/237#discussion_r91866020","pull_request_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237","_links":{"self":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/comments/91866020"},"html":{"href":"https://github.com/AliSoftware/SwiftGen/pull/237#discussion_r91866020"},"pull_request":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237"}}},"pull_request":{"url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237","id":97465345,"html_url":"https://github.com/AliSoftware/SwiftGen/pull/237","diff_url":"https://github.com/AliSoftware/SwiftGen/pull/237.diff","patch_url":"https://github.com/AliSoftware/SwiftGen/pull/237.patch","issue_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/237","number":237,"state":"open","locked":false,"title":"Template recursion","user":{"login":"djbe","id":641356,"avatar_url":"https://avatars.githubusercontent.com/u/641356?v=3","gravatar_id":"","url":"https://api.github.com/users/djbe","html_url":"https://github.com/djbe","followers_url":"https://api.github.com/users/djbe/followers","following_url":"https://api.github.com/users/djbe/following{/other_user}","gists_url":"https://api.github.com/users/djbe/gists{/gist_id}","starred_url":"https://api.github.com/users/djbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djbe/subscriptions","organizations_url":"https://api.github.com/users/djbe/orgs","repos_url":"https://api.github.com/users/djbe/repos","events_url":"https://api.github.com/users/djbe/events{/privacy}","received_events_url":"https://api.github.com/users/djbe/received_events","type":"User","site_admin":false},"body":"This defines 2 stencil tags:\r\n - `define`: This defines a `CallableBlock`, accepts the following arguments:\r\n   - _name_: the block will be stored in a variable of this name (in the current context stack).\r\n   - _parameter names_ (0 or more): will then be available inside the block using `args.parameterName`.\r\n- `call`: This calls a `CallableBlock`, accepts the following arguments:\r\n  - _name_: the name of the variable pointing to a callable block.\r\n  -  _arguments_ (0 or more): will be resolved and passed along to the block. The number of arguments must match the number of parameters.\r\n\r\nWhen a block is called, it pushes a context (same as the `for` and inheritance tags). This means that variables defined inside this context won't be available outside of it.","created_at":"2016-12-11T17:13:35Z","updated_at":"2016-12-11T21:35:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2e6873fb3e059681b21c4b321954560f339d2d04","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/AliSoftware/SwiftGen/milestones/12","html_url":"https://github.com/AliSoftware/SwiftGen/milestone/12","labels_url":"https://api.github.com/repos/AliSoftware/SwiftGen/milestones/12/labels","id":2146790,"number":12,"title":"Next minor (4.1.0)","description":"Any new features, but only additive ones. Nothing that breaks code for existing users.","creator":{"login":"djbe","id":641356,"avatar_url":"https://avatars.githubusercontent.com/u/641356?v=3","gravatar_id":"","url":"https://api.github.com/users/djbe","html_url":"https://github.com/djbe","followers_url":"https://api.github.com/users/djbe/followers","following_url":"https://api.github.com/users/djbe/following{/other_user}","gists_url":"https://api.github.com/users/djbe/gists{/gist_id}","starred_url":"https://api.github.com/users/djbe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djbe/subscriptions","organizations_url":"https://api.github.com/users/djbe/orgs","repos_url":"https://api.github.com/users/djbe/repos","events_url":"https://api.github.com/users/djbe/events{/privacy}","received_events_url":"https://api.github.com/users/djbe/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":2,"state":"open","created_at":"2016-11-20T18:33:29Z","updated_at":"2016-12-11T20:56:56Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237/commits","review_comments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237/comments","review_comment_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/237/comments","statuses_url":"https://api.github.com/repos/AliSoftware/SwiftGen/statuses/05a2e12a128797aa63ac035af57582587c44fa90","head":{"label":"AliSoftware:feature/template-recursion","ref":"feature/template-recursion","sha":"05a2e12a128797aa63ac035af57582587c44fa90","user":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars.githubusercontent.com/u/216089?v=3","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"repo":{"id":39166950,"name":"SwiftGen","full_name":"AliSoftware/SwiftGen","owner":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars.githubusercontent.com/u/216089?v=3","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AliSoftware/SwiftGen","description":"The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!","fork":false,"url":"https://api.github.com/repos/AliSoftware/SwiftGen","forks_url":"https://api.github.com/repos/AliSoftware/SwiftGen/forks","keys_url":"https://api.github.com/repos/AliSoftware/SwiftGen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AliSoftware/SwiftGen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AliSoftware/SwiftGen/teams","hooks_url":"https://api.github.com/repos/AliSoftware/SwiftGen/hooks","issue_events_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/events{/number}","events_url":"https://api.github.com/repos/AliSoftware/SwiftGen/events","assignees_url":"https://api.github.com/repos/AliSoftware/SwiftGen/assignees{/user}","branches_url":"https://api.github.com/repos/AliSoftware/SwiftGen/branches{/branch}","tags_url":"https://api.github.com/repos/AliSoftware/SwiftGen/tags","blobs_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/refs{/sha}","trees_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AliSoftware/SwiftGen/statuses/{sha}","languages_url":"https://api.github.com/repos/AliSoftware/SwiftGen/languages","stargazers_url":"https://api.github.com/repos/AliSoftware/SwiftGen/stargazers","contributors_url":"https://api.github.com/repos/AliSoftware/SwiftGen/contributors","subscribers_url":"https://api.github.com/repos/AliSoftware/SwiftGen/subscribers","subscription_url":"https://api.github.com/repos/AliSoftware/SwiftGen/subscription","commits_url":"https://api.github.com/repos/AliSoftware/SwiftGen/commits{/sha}","git_commits_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/commits{/sha}","comments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/comments{/number}","issue_comment_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/comments{/number}","contents_url":"https://api.github.com/repos/AliSoftware/SwiftGen/contents/{+path}","compare_url":"https://api.github.com/repos/AliSoftware/SwiftGen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AliSoftware/SwiftGen/merges","archive_url":"https://api.github.com/repos/AliSoftware/SwiftGen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AliSoftware/SwiftGen/downloads","issues_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues{/number}","pulls_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls{/number}","milestones_url":"https://api.github.com/repos/AliSoftware/SwiftGen/milestones{/number}","notifications_url":"https://api.github.com/repos/AliSoftware/SwiftGen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AliSoftware/SwiftGen/labels{/name}","releases_url":"https://api.github.com/repos/AliSoftware/SwiftGen/releases{/id}","deployments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/deployments","created_at":"2015-07-15T23:58:44Z","updated_at":"2016-12-11T19:21:48Z","pushed_at":"2016-12-11T21:14:01Z","git_url":"git://github.com/AliSoftware/SwiftGen.git","ssh_url":"git@github.com:AliSoftware/SwiftGen.git","clone_url":"https://github.com/AliSoftware/SwiftGen.git","svn_url":"https://github.com/AliSoftware/SwiftGen","homepage":"","size":5912,"stargazers_count":2898,"watchers_count":2898,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":189,"mirror_url":null,"open_issues_count":38,"forks":189,"open_issues":38,"watchers":2898,"default_branch":"master"}},"base":{"label":"AliSoftware:master","ref":"master","sha":"250fa7c85eb28f75645ebcac022ff1e1c267b67f","user":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars.githubusercontent.com/u/216089?v=3","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"repo":{"id":39166950,"name":"SwiftGen","full_name":"AliSoftware/SwiftGen","owner":{"login":"AliSoftware","id":216089,"avatar_url":"https://avatars.githubusercontent.com/u/216089?v=3","gravatar_id":"","url":"https://api.github.com/users/AliSoftware","html_url":"https://github.com/AliSoftware","followers_url":"https://api.github.com/users/AliSoftware/followers","following_url":"https://api.github.com/users/AliSoftware/following{/other_user}","gists_url":"https://api.github.com/users/AliSoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/AliSoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AliSoftware/subscriptions","organizations_url":"https://api.github.com/users/AliSoftware/orgs","repos_url":"https://api.github.com/users/AliSoftware/repos","events_url":"https://api.github.com/users/AliSoftware/events{/privacy}","received_events_url":"https://api.github.com/users/AliSoftware/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AliSoftware/SwiftGen","description":"The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!","fork":false,"url":"https://api.github.com/repos/AliSoftware/SwiftGen","forks_url":"https://api.github.com/repos/AliSoftware/SwiftGen/forks","keys_url":"https://api.github.com/repos/AliSoftware/SwiftGen/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AliSoftware/SwiftGen/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AliSoftware/SwiftGen/teams","hooks_url":"https://api.github.com/repos/AliSoftware/SwiftGen/hooks","issue_events_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/events{/number}","events_url":"https://api.github.com/repos/AliSoftware/SwiftGen/events","assignees_url":"https://api.github.com/repos/AliSoftware/SwiftGen/assignees{/user}","branches_url":"https://api.github.com/repos/AliSoftware/SwiftGen/branches{/branch}","tags_url":"https://api.github.com/repos/AliSoftware/SwiftGen/tags","blobs_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/refs{/sha}","trees_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AliSoftware/SwiftGen/statuses/{sha}","languages_url":"https://api.github.com/repos/AliSoftware/SwiftGen/languages","stargazers_url":"https://api.github.com/repos/AliSoftware/SwiftGen/stargazers","contributors_url":"https://api.github.com/repos/AliSoftware/SwiftGen/contributors","subscribers_url":"https://api.github.com/repos/AliSoftware/SwiftGen/subscribers","subscription_url":"https://api.github.com/repos/AliSoftware/SwiftGen/subscription","commits_url":"https://api.github.com/repos/AliSoftware/SwiftGen/commits{/sha}","git_commits_url":"https://api.github.com/repos/AliSoftware/SwiftGen/git/commits{/sha}","comments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/comments{/number}","issue_comment_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/comments{/number}","contents_url":"https://api.github.com/repos/AliSoftware/SwiftGen/contents/{+path}","compare_url":"https://api.github.com/repos/AliSoftware/SwiftGen/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AliSoftware/SwiftGen/merges","archive_url":"https://api.github.com/repos/AliSoftware/SwiftGen/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AliSoftware/SwiftGen/downloads","issues_url":"https://api.github.com/repos/AliSoftware/SwiftGen/issues{/number}","pulls_url":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls{/number}","milestones_url":"https://api.github.com/repos/AliSoftware/SwiftGen/milestones{/number}","notifications_url":"https://api.github.com/repos/AliSoftware/SwiftGen/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AliSoftware/SwiftGen/labels{/name}","releases_url":"https://api.github.com/repos/AliSoftware/SwiftGen/releases{/id}","deployments_url":"https://api.github.com/repos/AliSoftware/SwiftGen/deployments","created_at":"2015-07-15T23:58:44Z","updated_at":"2016-12-11T19:21:48Z","pushed_at":"2016-12-11T21:14:01Z","git_url":"git://github.com/AliSoftware/SwiftGen.git","ssh_url":"git@github.com:AliSoftware/SwiftGen.git","clone_url":"https://github.com/AliSoftware/SwiftGen.git","svn_url":"https://github.com/AliSoftware/SwiftGen","homepage":"","size":5912,"stargazers_count":2898,"watchers_count":2898,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":189,"mirror_url":null,"open_issues_count":38,"forks":189,"open_issues":38,"watchers":2898,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237"},"html":{"href":"https://github.com/AliSoftware/SwiftGen/pull/237"},"issue":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/237"},"comments":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/issues/237/comments"},"review_comments":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237/comments"},"review_comment":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/pulls/237/commits"},"statuses":{"href":"https://api.github.com/repos/AliSoftware/SwiftGen/statuses/05a2e12a128797aa63ac035af57582587c44fa90"}}}}
{"actor":{"display_login":"AliSoftware"}}