{"action":"created","issue":{"url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/234","repository_url":"https://api.github.com/repos/asciidoctor/asciidoctor.js","labels_url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/234/comments","events_url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/234/events","html_url":"https://github.com/asciidoctor/asciidoctor.js/issues/234","id":180474503,"number":234,"title":"Improvements about nil for Asciidoctor.js","user":{"login":"rahmanusta","id":1158804,"avatar_url":"https://avatars.githubusercontent.com/u/1158804?v=3","gravatar_id":"","url":"https://api.github.com/users/rahmanusta","html_url":"https://github.com/rahmanusta","followers_url":"https://api.github.com/users/rahmanusta/followers","following_url":"https://api.github.com/users/rahmanusta/following{/other_user}","gists_url":"https://api.github.com/users/rahmanusta/gists{/gist_id}","starred_url":"https://api.github.com/users/rahmanusta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rahmanusta/subscriptions","organizations_url":"https://api.github.com/users/rahmanusta/orgs","repos_url":"https://api.github.com/users/rahmanusta/repos","events_url":"https://api.github.com/users/rahmanusta/events{/privacy}","received_events_url":"https://api.github.com/users/rahmanusta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-01T19:19:07Z","updated_at":"2016-10-06T21:02:25Z","closed_at":null,"body":"When we convert Ruby code to JS code, nil is represented as an object that constructed from `$NilClass`.\r\n\r\nWe can check whether an object is **nil** like `object[\"$nil?\"]`. Can we create an alias to comply with the following usage: `object.isNil()` or `object.$isNil()` ? I think using dot notation is clear than the bracket notation, but **?** is not an allowed character for JS names.\r\n\r\nAlso, if an object is `nil`, calling its `toString` function produces \"$$id class apply\" like text. You can see it at Jade templates in asciidoctor-reveal.js package.\r\n\r\nFor example;\r\n\r\nConverting this `\"== Hello _Rahman_\"` produces the following HTML output:\r\n\r\n```\r\n<section>\r\n  <section id=\"_hello_em_class_id_apply_call_rahman_em\" data-transition=\"\" data-transition-speed=\"\" data-background=\"\" data-background-size=\"\" data-background-repeat=\"\" data-background-transition=\"\">\r\n    <h2>Hello <em class=\"$$id apply call\">Rahman</em></h2>\r\n  </section>\r\n</section>\r\n```\r\n\r\nIf we override nil's `toString` to return just `null`, I think it will be better for Asciidoctor.js.\r\n\r\nWhat do you think for these suggestions?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/comments/252087651","html_url":"https://github.com/asciidoctor/asciidoctor.js/issues/234#issuecomment-252087651","issue_url":"https://api.github.com/repos/asciidoctor/asciidoctor.js/issues/234","id":252087651,"user":{"login":"Mogztter","id":333276,"avatar_url":"https://avatars.githubusercontent.com/u/333276?v=3","gravatar_id":"","url":"https://api.github.com/users/Mogztter","html_url":"https://github.com/Mogztter","followers_url":"https://api.github.com/users/Mogztter/followers","following_url":"https://api.github.com/users/Mogztter/following{/other_user}","gists_url":"https://api.github.com/users/Mogztter/gists{/gist_id}","starred_url":"https://api.github.com/users/Mogztter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mogztter/subscriptions","organizations_url":"https://api.github.com/users/Mogztter/orgs","repos_url":"https://api.github.com/users/Mogztter/repos","events_url":"https://api.github.com/users/Mogztter/events{/privacy}","received_events_url":"https://api.github.com/users/Mogztter/received_events","type":"User","site_admin":false},"created_at":"2016-10-06T21:02:25Z","updated_at":"2016-10-06T21:02:25Z","body":"One idea is to assign `Opal.nil` to empty string: \r\n```javascript\r\nOpal.nil = '';\r\n```\r\nUnfortunately this is not working because in Ruby you can call methods on nil class (for instance `empty?`):\r\n\r\n```\r\n    empty?: undefined method `empty?' for nil\r\n        at Opal.defs.TMP_1 [as $new] (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:4853:15)\r\n        at NilClass_alloc.ːmethod_missing (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:3410:54)\r\n        at NilClass_alloc.method_missing_stub [as $empty?] (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:1006:35)\r\n        at $DocBook45Converter.ːdocument_ns_attributes (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:34868:35)\r\n        at $DocBook45Converter.ːdocument (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:34942:53)\r\n        at $DocBook45Converter.ː__send__ (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:3228:21)\r\n        at $DocBook45Converter.ːconvert (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:20546:24)\r\n        at $Document.ːconvert (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:26762:35)\r\n        at module_constructor.ːconvert (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:32086:22)\r\n        at module_constructor.Opal.Asciidoctor.$$class.$$proto.convert (/home/guillaume/workspace/opensource/asciidoctor.js/build/bower.spec.all.js:33361:15)\r\n```\r\n\r\nAnother idea is to use the wrapper API in the Jade templates. In your example, we could return an empty string if the `role` method returns `Opal.nil`: https://github.com/asciidoctor/asciidoctor.js/blob/76964f479996b740c37e09e0f4b655dce0a927d0/src/asciidoctor-core-api.js#L110"}}
{"actor":{"display_login":"Mogztter"}}