{"action":"created","issue":{"url":"https://api.github.com/repos/muut/riotjs/issues/291","labels_url":"https://api.github.com/repos/muut/riotjs/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/muut/riotjs/issues/291/comments","events_url":"https://api.github.com/repos/muut/riotjs/issues/291/events","html_url":"https://github.com/muut/riotjs/issues/291","id":56385614,"number":291,"title":"How to expose global libs to nested custom tags ?","user":{"login":"turingou","id":1269537,"avatar_url":"https://avatars.githubusercontent.com/u/1269537?v=3","gravatar_id":"","url":"https://api.github.com/users/turingou","html_url":"https://github.com/turingou","followers_url":"https://api.github.com/users/turingou/followers","following_url":"https://api.github.com/users/turingou/following{/other_user}","gists_url":"https://api.github.com/users/turingou/gists{/gist_id}","starred_url":"https://api.github.com/users/turingou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turingou/subscriptions","organizations_url":"https://api.github.com/users/turingou/orgs","repos_url":"https://api.github.com/users/turingou/repos","events_url":"https://api.github.com/users/turingou/events{/privacy}","received_events_url":"https://api.github.com/users/turingou/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-03T14:39:42Z","updated_at":"2015-04-02T16:34:29Z","closed_at":"2015-02-04T06:36:11Z","body":"First of all, I want to inject some of my utils functions into custom tags,\r\nAssume we've markup below:\r\n\r\n```html\r\n<my-article>\r\n  { opts.utils.someParser() }\r\n  <my-content></my-content>\r\n  <my-comments />\r\n</my-article>\r\n```\r\nWhich means in `my-content` tag, I should trigger `utils.someParser()` by `parent.opts.someParser()`, it seems not maintainable when the nest grows.\r\n\r\nSo Im trying to expose `utils` as a global var `window._utils` instead, and trigger them by ` { _utils.someParser() } ` which was not working as well.\r\n\r\nFinally I found a workaround, is to make a refer object in each of these custom tags:\r\n\r\n```html\r\n<my-article>\r\n  { utils.someParser() }\r\n  <my-content></my-content>\r\n  <my-comments />\r\n\r\n  this.utils = window._utils;\r\n</my-article>\r\n```\r\n\r\nIn `<my-content>`\r\n\r\n```html\r\n<my-content>\r\n  { utils.someParser() }\r\n  <my-entry />\r\n\r\n  this.utils = window._utils;\r\n</my-content>\r\n```\r\n\r\nThis works but not cool. May be there is another approach ?"},"comment":{"url":"https://api.github.com/repos/muut/riotjs/issues/comments/88968134","html_url":"https://github.com/muut/riotjs/issues/291#issuecomment-88968134","issue_url":"https://api.github.com/repos/muut/riotjs/issues/291","id":88968134,"user":{"login":"jimknight","id":248317,"avatar_url":"https://avatars.githubusercontent.com/u/248317?v=3","gravatar_id":"","url":"https://api.github.com/users/jimknight","html_url":"https://github.com/jimknight","followers_url":"https://api.github.com/users/jimknight/followers","following_url":"https://api.github.com/users/jimknight/following{/other_user}","gists_url":"https://api.github.com/users/jimknight/gists{/gist_id}","starred_url":"https://api.github.com/users/jimknight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimknight/subscriptions","organizations_url":"https://api.github.com/users/jimknight/orgs","repos_url":"https://api.github.com/users/jimknight/repos","events_url":"https://api.github.com/users/jimknight/events{/privacy}","received_events_url":"https://api.github.com/users/jimknight/received_events","type":"User","site_admin":false},"created_at":"2015-04-02T16:34:29Z","updated_at":"2015-04-02T16:34:29Z","body":"Thanks for the plunker. I was doing this.parent.parent... knowing it was not right."}}