{"action":"created","comment":{"url":"https://api.github.com/repos/linkedin/dustjs/pulls/comments/29173657","id":29173657,"diff_hunk":"@@ -112,41 +112,79 @@\n     return stream;\n   };\n \n+  /**\n+   * Extracts a template function (body_0) from whatever is passed.\n+   * @param nameOrTemplate {*} Could be:\n+   *   - the name of a template to load from cache\n+   *   - a CommonJS-compiled template (a function with a `template` property)\n+   *   - a template function\n+   * @param loadFromCache {Boolean} if false, don't look in the cache\n+   * @return {Function} a template function, if found\n+   */\n+  function getTemplate(nameOrTemplate, loadFromCache/*=true*/) {\n+    if(!nameOrTemplate) {\n+      return;\n+    }\n+    if(typeof nameOrTemplate === 'function' && nameOrTemplate.template) {\n+      // Sugar away CommonJS module templates\n+      return nameOrTemplate.template;\n+    }\n+    if(dust.isTemplateFn(nameOrTemplate)) {\n+      // Template functions passed directly\n+      return nameOrTemplate;\n+    }\n+    if(loadFromCache !== false) {\n+      // Try loading a template with this name from cache\n+      return dust.cache[nameOrTemplate];\n+    }\n+  }\n+\n   function load(nameOrTemplate, chunk, context) {\n     if(!nameOrTemplate) {\n       return chunk.setError(new Error('No template or template name provided to render'));\n     }\n \n-    if(!dust.config.cache) {\n+    if(dust.config.cache === false) {","path":"lib/dust.js","position":37,"original_position":37,"commit_id":"8555c8087e7f969b87bce146aff27ad2acafb677","original_commit_id":"a64a93f9be1601c777e2b20426f5c460fec06fb0","user":{"login":"sethkinast","id":1399532,"avatar_url":"https://avatars.githubusercontent.com/u/1399532?v=3","gravatar_id":"","url":"https://api.github.com/users/sethkinast","html_url":"https://github.com/sethkinast","followers_url":"https://api.github.com/users/sethkinast/followers","following_url":"https://api.github.com/users/sethkinast/following{/other_user}","gists_url":"https://api.github.com/users/sethkinast/gists{/gist_id}","starred_url":"https://api.github.com/users/sethkinast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethkinast/subscriptions","organizations_url":"https://api.github.com/users/sethkinast/orgs","repos_url":"https://api.github.com/users/sethkinast/repos","events_url":"https://api.github.com/users/sethkinast/events{/privacy}","received_events_url":"https://api.github.com/users/sethkinast/received_events","type":"User","site_admin":false},"body":"Makes sense. Naively I think I'd prefer to leave that to an `onLoad` implementor but I welcome issues / PRs.","created_at":"2015-04-27T18:10:42Z","updated_at":"2015-04-27T18:10:42Z","html_url":"https://github.com/linkedin/dustjs/pull/641#discussion_r29173657","pull_request_url":"https://api.github.com/repos/linkedin/dustjs/pulls/641","_links":{"self":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/comments/29173657"},"html":{"href":"https://github.com/linkedin/dustjs/pull/641#discussion_r29173657"},"pull_request":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/641"}}},"pull_request":{"url":"https://api.github.com/repos/linkedin/dustjs/pulls/641","id":33717621,"html_url":"https://github.com/linkedin/dustjs/pull/641","diff_url":"https://github.com/linkedin/dustjs/pull/641.diff","patch_url":"https://github.com/linkedin/dustjs/pull/641.patch","issue_url":"https://api.github.com/repos/linkedin/dustjs/issues/641","number":641,"state":"open","locked":false,"title":"Add a `cb(null, compiledTemplate)` signature to `dust.onLoad`","user":{"login":"sethkinast","id":1399532,"avatar_url":"https://avatars.githubusercontent.com/u/1399532?v=3","gravatar_id":"","url":"https://api.github.com/users/sethkinast","html_url":"https://github.com/sethkinast","followers_url":"https://api.github.com/users/sethkinast/followers","following_url":"https://api.github.com/users/sethkinast/following{/other_user}","gists_url":"https://api.github.com/users/sethkinast/gists{/gist_id}","starred_url":"https://api.github.com/users/sethkinast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethkinast/subscriptions","organizations_url":"https://api.github.com/users/sethkinast/orgs","repos_url":"https://api.github.com/users/sethkinast/repos","events_url":"https://api.github.com/users/sethkinast/events{/privacy}","received_events_url":"https://api.github.com/users/sethkinast/received_events","type":"User","site_admin":false},"body":"Currently you can either call `cb()`, in which case Dust will try to load the original name from cache,\r\nor `cb(null, src)`, and Dust will try to compile `src` and register it under the original name.\r\n\r\nSometimes, you might want to dynamically load one of several templates based on the original name.\r\n\r\nThis change adds `cb(null, compiledTemplate)` so you can load any template from cache or the filesystem,\r\nregister it manually (or not at all), and render it.\r\n\r\nThe returned template will NOT be registered under the original name.","created_at":"2015-04-20T23:52:44Z","updated_at":"2015-04-27T18:10:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ec051a0b36180eadb5c07d4894b51cafdb0b42e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linkedin/dustjs/pulls/641/commits","review_comments_url":"https://api.github.com/repos/linkedin/dustjs/pulls/641/comments","review_comment_url":"https://api.github.com/repos/linkedin/dustjs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linkedin/dustjs/issues/641/comments","statuses_url":"https://api.github.com/repos/linkedin/dustjs/statuses/8555c8087e7f969b87bce146aff27ad2acafb677","head":{"label":"sethkinast:onLoad","ref":"onLoad","sha":"8555c8087e7f969b87bce146aff27ad2acafb677","user":{"login":"sethkinast","id":1399532,"avatar_url":"https://avatars.githubusercontent.com/u/1399532?v=3","gravatar_id":"","url":"https://api.github.com/users/sethkinast","html_url":"https://github.com/sethkinast","followers_url":"https://api.github.com/users/sethkinast/followers","following_url":"https://api.github.com/users/sethkinast/following{/other_user}","gists_url":"https://api.github.com/users/sethkinast/gists{/gist_id}","starred_url":"https://api.github.com/users/sethkinast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethkinast/subscriptions","organizations_url":"https://api.github.com/users/sethkinast/orgs","repos_url":"https://api.github.com/users/sethkinast/repos","events_url":"https://api.github.com/users/sethkinast/events{/privacy}","received_events_url":"https://api.github.com/users/sethkinast/received_events","type":"User","site_admin":false},"repo":{"id":23441887,"name":"dustjs","full_name":"sethkinast/dustjs","owner":{"login":"sethkinast","id":1399532,"avatar_url":"https://avatars.githubusercontent.com/u/1399532?v=3","gravatar_id":"","url":"https://api.github.com/users/sethkinast","html_url":"https://github.com/sethkinast","followers_url":"https://api.github.com/users/sethkinast/followers","following_url":"https://api.github.com/users/sethkinast/following{/other_user}","gists_url":"https://api.github.com/users/sethkinast/gists{/gist_id}","starred_url":"https://api.github.com/users/sethkinast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethkinast/subscriptions","organizations_url":"https://api.github.com/users/sethkinast/orgs","repos_url":"https://api.github.com/users/sethkinast/repos","events_url":"https://api.github.com/users/sethkinast/events{/privacy}","received_events_url":"https://api.github.com/users/sethkinast/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sethkinast/dustjs","description":"Asynchronous templates for the browser and node.js","fork":true,"url":"https://api.github.com/repos/sethkinast/dustjs","forks_url":"https://api.github.com/repos/sethkinast/dustjs/forks","keys_url":"https://api.github.com/repos/sethkinast/dustjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sethkinast/dustjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sethkinast/dustjs/teams","hooks_url":"https://api.github.com/repos/sethkinast/dustjs/hooks","issue_events_url":"https://api.github.com/repos/sethkinast/dustjs/issues/events{/number}","events_url":"https://api.github.com/repos/sethkinast/dustjs/events","assignees_url":"https://api.github.com/repos/sethkinast/dustjs/assignees{/user}","branches_url":"https://api.github.com/repos/sethkinast/dustjs/branches{/branch}","tags_url":"https://api.github.com/repos/sethkinast/dustjs/tags","blobs_url":"https://api.github.com/repos/sethkinast/dustjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sethkinast/dustjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sethkinast/dustjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/sethkinast/dustjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sethkinast/dustjs/statuses/{sha}","languages_url":"https://api.github.com/repos/sethkinast/dustjs/languages","stargazers_url":"https://api.github.com/repos/sethkinast/dustjs/stargazers","contributors_url":"https://api.github.com/repos/sethkinast/dustjs/contributors","subscribers_url":"https://api.github.com/repos/sethkinast/dustjs/subscribers","subscription_url":"https://api.github.com/repos/sethkinast/dustjs/subscription","commits_url":"https://api.github.com/repos/sethkinast/dustjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/sethkinast/dustjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/sethkinast/dustjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/sethkinast/dustjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/sethkinast/dustjs/contents/{+path}","compare_url":"https://api.github.com/repos/sethkinast/dustjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sethkinast/dustjs/merges","archive_url":"https://api.github.com/repos/sethkinast/dustjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sethkinast/dustjs/downloads","issues_url":"https://api.github.com/repos/sethkinast/dustjs/issues{/number}","pulls_url":"https://api.github.com/repos/sethkinast/dustjs/pulls{/number}","milestones_url":"https://api.github.com/repos/sethkinast/dustjs/milestones{/number}","notifications_url":"https://api.github.com/repos/sethkinast/dustjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sethkinast/dustjs/labels{/name}","releases_url":"https://api.github.com/repos/sethkinast/dustjs/releases{/id}","created_at":"2014-08-28T20:27:51Z","updated_at":"2015-04-18T00:39:26Z","pushed_at":"2015-04-24T19:58:32Z","git_url":"git://github.com/sethkinast/dustjs.git","ssh_url":"git@github.com:sethkinast/dustjs.git","clone_url":"https://github.com/sethkinast/dustjs.git","svn_url":"https://github.com/sethkinast/dustjs","homepage":"","size":10211,"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":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"linkedin:master","ref":"master","sha":"8a62cff70ead366b4924a6e249040e538855d988","user":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"repo":{"id":3813151,"name":"dustjs","full_name":"linkedin/dustjs","owner":{"login":"linkedin","id":357098,"avatar_url":"https://avatars.githubusercontent.com/u/357098?v=3","gravatar_id":"","url":"https://api.github.com/users/linkedin","html_url":"https://github.com/linkedin","followers_url":"https://api.github.com/users/linkedin/followers","following_url":"https://api.github.com/users/linkedin/following{/other_user}","gists_url":"https://api.github.com/users/linkedin/gists{/gist_id}","starred_url":"https://api.github.com/users/linkedin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linkedin/subscriptions","organizations_url":"https://api.github.com/users/linkedin/orgs","repos_url":"https://api.github.com/users/linkedin/repos","events_url":"https://api.github.com/users/linkedin/events{/privacy}","received_events_url":"https://api.github.com/users/linkedin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linkedin/dustjs","description":"Asynchronous Javascript templating for the browser and server","fork":false,"url":"https://api.github.com/repos/linkedin/dustjs","forks_url":"https://api.github.com/repos/linkedin/dustjs/forks","keys_url":"https://api.github.com/repos/linkedin/dustjs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linkedin/dustjs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linkedin/dustjs/teams","hooks_url":"https://api.github.com/repos/linkedin/dustjs/hooks","issue_events_url":"https://api.github.com/repos/linkedin/dustjs/issues/events{/number}","events_url":"https://api.github.com/repos/linkedin/dustjs/events","assignees_url":"https://api.github.com/repos/linkedin/dustjs/assignees{/user}","branches_url":"https://api.github.com/repos/linkedin/dustjs/branches{/branch}","tags_url":"https://api.github.com/repos/linkedin/dustjs/tags","blobs_url":"https://api.github.com/repos/linkedin/dustjs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linkedin/dustjs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linkedin/dustjs/git/refs{/sha}","trees_url":"https://api.github.com/repos/linkedin/dustjs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linkedin/dustjs/statuses/{sha}","languages_url":"https://api.github.com/repos/linkedin/dustjs/languages","stargazers_url":"https://api.github.com/repos/linkedin/dustjs/stargazers","contributors_url":"https://api.github.com/repos/linkedin/dustjs/contributors","subscribers_url":"https://api.github.com/repos/linkedin/dustjs/subscribers","subscription_url":"https://api.github.com/repos/linkedin/dustjs/subscription","commits_url":"https://api.github.com/repos/linkedin/dustjs/commits{/sha}","git_commits_url":"https://api.github.com/repos/linkedin/dustjs/git/commits{/sha}","comments_url":"https://api.github.com/repos/linkedin/dustjs/comments{/number}","issue_comment_url":"https://api.github.com/repos/linkedin/dustjs/issues/comments{/number}","contents_url":"https://api.github.com/repos/linkedin/dustjs/contents/{+path}","compare_url":"https://api.github.com/repos/linkedin/dustjs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linkedin/dustjs/merges","archive_url":"https://api.github.com/repos/linkedin/dustjs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linkedin/dustjs/downloads","issues_url":"https://api.github.com/repos/linkedin/dustjs/issues{/number}","pulls_url":"https://api.github.com/repos/linkedin/dustjs/pulls{/number}","milestones_url":"https://api.github.com/repos/linkedin/dustjs/milestones{/number}","notifications_url":"https://api.github.com/repos/linkedin/dustjs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linkedin/dustjs/labels{/name}","releases_url":"https://api.github.com/repos/linkedin/dustjs/releases{/id}","created_at":"2012-03-23T22:20:39Z","updated_at":"2015-04-27T10:51:30Z","pushed_at":"2015-04-24T19:58:51Z","git_url":"git://github.com/linkedin/dustjs.git","ssh_url":"git@github.com:linkedin/dustjs.git","clone_url":"https://github.com/linkedin/dustjs.git","svn_url":"https://github.com/linkedin/dustjs","homepage":"http://dustjs.com","size":13674,"stargazers_count":1797,"watchers_count":1797,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":333,"mirror_url":null,"open_issues_count":46,"forks":333,"open_issues":46,"watchers":1797,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/641"},"html":{"href":"https://github.com/linkedin/dustjs/pull/641"},"issue":{"href":"https://api.github.com/repos/linkedin/dustjs/issues/641"},"comments":{"href":"https://api.github.com/repos/linkedin/dustjs/issues/641/comments"},"review_comments":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/641/comments"},"review_comment":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linkedin/dustjs/pulls/641/commits"},"statuses":{"href":"https://api.github.com/repos/linkedin/dustjs/statuses/8555c8087e7f969b87bce146aff27ad2acafb677"}}}}