{"action":"created","issue":{"url":"https://api.github.com/repos/format-message/format-message/issues/57","repository_url":"https://api.github.com/repos/format-message/format-message","labels_url":"https://api.github.com/repos/format-message/format-message/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/format-message/format-message/issues/57/comments","events_url":"https://api.github.com/repos/format-message/format-message/issues/57/events","html_url":"https://github.com/format-message/format-message/issues/57","id":181233936,"number":57,"title":"Allow for nested objects as data/keys","user":{"login":"minimalmonkey","id":2965339,"avatar_url":"https://avatars.githubusercontent.com/u/2965339?v=3","gravatar_id":"","url":"https://api.github.com/users/minimalmonkey","html_url":"https://github.com/minimalmonkey","followers_url":"https://api.github.com/users/minimalmonkey/followers","following_url":"https://api.github.com/users/minimalmonkey/following{/other_user}","gists_url":"https://api.github.com/users/minimalmonkey/gists{/gist_id}","starred_url":"https://api.github.com/users/minimalmonkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minimalmonkey/subscriptions","organizations_url":"https://api.github.com/users/minimalmonkey/orgs","repos_url":"https://api.github.com/users/minimalmonkey/repos","events_url":"https://api.github.com/users/minimalmonkey/events{/privacy}","received_events_url":"https://api.github.com/users/minimalmonkey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-05T18:42:38Z","updated_at":"2016-10-05T19:32:18Z","closed_at":null,"body":"Firstly, thanks so much for this lib. It's really useful for a project I'm currently working on and the code is really easy to follow. Awesome work! 🙌 \r\n\r\nFor my project I'm using nested data objects that I pass to the `format` method. Right now I have to flatten the object for it to work, for example this:\r\n\r\n```\r\nvar data = {\r\n  'user': 'Steve',\r\n  'members': {\r\n    'count': 10\r\n  }\r\n};\r\n```\r\n\r\nbecomes:\r\n\r\n```\r\nvar data = {\r\n  'user': 'Steve',\r\n  'members.count': 10\r\n};\r\n```\r\n\r\nThis works fine but when the data object is huge, with lots of nested data we don't care about, it becomes a bit of a performance issue.\r\n\r\nA work around for this would be to update the `interpretSimple` function to be:\r\n\r\n```\r\nfunction interpretSimple (id) {\r\n  return function format (args) {\r\n    var parts = id.split('.');\r\n    if (parts.length > 1) {\r\n      var i = 0;\r\n      var l = parts.length;\r\n      var a = args;\r\n      for (i; i < l; i++) {\r\n        a = a[parts[i]];\r\n        if (!a) return '' + args[id];\r\n      }\r\n      return '' + a;\r\n    }\r\n    return '' + args[id];\r\n  }\r\n}\r\n```\r\n\r\nThis would look for nested variables in an object but would fallback to how things currently work, so would be a minor update / backwards compatible.\r\n\r\nIs this something that could be consider? If yes I can put together a PR today along with updated unit tests etc."},"comment":{"url":"https://api.github.com/repos/format-message/format-message/issues/comments/251775244","html_url":"https://github.com/format-message/format-message/issues/57#issuecomment-251775244","issue_url":"https://api.github.com/repos/format-message/format-message/issues/57","id":251775244,"user":{"login":"thetalecrafter","id":270632,"avatar_url":"https://avatars.githubusercontent.com/u/270632?v=3","gravatar_id":"","url":"https://api.github.com/users/thetalecrafter","html_url":"https://github.com/thetalecrafter","followers_url":"https://api.github.com/users/thetalecrafter/followers","following_url":"https://api.github.com/users/thetalecrafter/following{/other_user}","gists_url":"https://api.github.com/users/thetalecrafter/gists{/gist_id}","starred_url":"https://api.github.com/users/thetalecrafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thetalecrafter/subscriptions","organizations_url":"https://api.github.com/users/thetalecrafter/orgs","repos_url":"https://api.github.com/users/thetalecrafter/repos","events_url":"https://api.github.com/users/thetalecrafter/events{/privacy}","received_events_url":"https://api.github.com/users/thetalecrafter/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T19:32:18Z","updated_at":"2016-10-05T19:32:18Z","body":"We should definitely support that! I'd love a PR.\r\n\r\nIt's probably more complicated than just an update to interpret, though. We'd want it to be supported everywhere. A PR wouldn't need to cover every case, but I'd want them all covered before releasing."}}
{"actor":{"display_login":"thetalecrafter"}}