{"action":"created","issue":{"url":"https://api.github.com/repos/valotas/mustache4dart/issues/39","labels_url":"https://api.github.com/repos/valotas/mustache4dart/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/valotas/mustache4dart/issues/39/comments","events_url":"https://api.github.com/repos/valotas/mustache4dart/issues/39/events","html_url":"https://github.com/valotas/mustache4dart/issues/39","id":56319255,"number":39,"title":"lambdas and nested templates","user":{"login":"sethladd","id":5479,"avatar_url":"https://avatars.githubusercontent.com/u/5479?v=3","gravatar_id":"","url":"https://api.github.com/users/sethladd","html_url":"https://github.com/sethladd","followers_url":"https://api.github.com/users/sethladd/followers","following_url":"https://api.github.com/users/sethladd/following{/other_user}","gists_url":"https://api.github.com/users/sethladd/gists{/gist_id}","starred_url":"https://api.github.com/users/sethladd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethladd/subscriptions","organizations_url":"https://api.github.com/users/sethladd/orgs","repos_url":"https://api.github.com/users/sethladd/repos","events_url":"https://api.github.com/users/sethladd/events{/privacy}","received_events_url":"https://api.github.com/users/sethladd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-03T01:10:57Z","updated_at":"2015-02-04T09:02:43Z","closed_at":null,"body":"Hi,\r\n\r\nHow do we handle this case?\r\n\r\nConsider:\r\n\r\n```\r\nvar map = {\r\n  'people': [\r\n    'bob': {\r\n      'firstName': 'Robert'\r\n    }\r\n  ]\r\n};\r\n```\r\n\r\n```\r\n{{#map.people}}\r\n  {{#lambda}}{{firstName}}{{/lambda}}\r\n{{/map.people}}\r\n```\r\n\r\nNotice that `firstName` is scoped to an implicit person.\r\n\r\nIf you remove the lambda, firstName is included in the output.\r\n\r\nIf you include the lambda, firstName is NOT included in the output. I believe this is because lambdas are required to do the mustache processing, and thus need to set the state correctly.\r\n\r\n```\r\nvar context = {\r\n  'map': map,\r\n  'lambda': lambda\r\n};\r\n\r\nString lambda(String input) {\r\n  return doAwesomeStuff(render(input, context)); // here's the issue. the context is scoped. how do I know the scope?\r\n}\r\n```\r\n\r\nProposed solution:\r\n\r\nIf mustache4dart could pass in the current context object into the lambda as the second argument, then all would be good:\r\n\r\n```\r\nString lambda(String input, currentContextPossiblyNested) {\r\n  return doAwesomeStuff(render(input, currentContextPossiblyNested)); \r\n}\r\n```\r\n\r\nWould something like that work?"},"comment":{"url":"https://api.github.com/repos/valotas/mustache4dart/issues/comments/72812531","html_url":"https://github.com/valotas/mustache4dart/issues/39#issuecomment-72812531","issue_url":"https://api.github.com/repos/valotas/mustache4dart/issues/39","id":72812531,"user":{"login":"valotas","id":26611,"avatar_url":"https://avatars.githubusercontent.com/u/26611?v=3","gravatar_id":"","url":"https://api.github.com/users/valotas","html_url":"https://github.com/valotas","followers_url":"https://api.github.com/users/valotas/followers","following_url":"https://api.github.com/users/valotas/following{/other_user}","gists_url":"https://api.github.com/users/valotas/gists{/gist_id}","starred_url":"https://api.github.com/users/valotas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/valotas/subscriptions","organizations_url":"https://api.github.com/users/valotas/orgs","repos_url":"https://api.github.com/users/valotas/repos","events_url":"https://api.github.com/users/valotas/events{/privacy}","received_events_url":"https://api.github.com/users/valotas/received_events","type":"User","site_admin":false},"created_at":"2015-02-04T09:02:43Z","updated_at":"2015-02-04T09:02:43Z","body":"Let me have a look at it tonight and get back to you."}}