{"action":"created","issue":{"url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/447","repository_url":"https://api.github.com/repos/asciidoctor/asciidoctorj","labels_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/447/labels{/name}","comments_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/447/comments","events_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/447/events","html_url":"https://github.com/asciidoctor/asciidoctorj/issues/447","id":148276643,"number":447,"title":"Setting context on blocks","user":{"login":"ygra","id":1692688,"avatar_url":"https://avatars.githubusercontent.com/u/1692688?v=3","gravatar_id":"","url":"https://api.github.com/users/ygra","html_url":"https://github.com/ygra","followers_url":"https://api.github.com/users/ygra/followers","following_url":"https://api.github.com/users/ygra/following{/other_user}","gists_url":"https://api.github.com/users/ygra/gists{/gist_id}","starred_url":"https://api.github.com/users/ygra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ygra/subscriptions","organizations_url":"https://api.github.com/users/ygra/orgs","repos_url":"https://api.github.com/users/ygra/repos","events_url":"https://api.github.com/users/ygra/events{/privacy}","received_events_url":"https://api.github.com/users/ygra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-14T07:31:26Z","updated_at":"2016-04-14T07:39:24Z","closed_at":null,"body":"This doesn't seem to be exposed in AsciidoctorJ, although it exists in Asciidoctor.\r\n\r\nI currently have a custom block processor that will parse parts of its contents as normal blocks and then set the context of those blocks to use custom templates for them (instead of handling them as normal paragraphs). I'm currently using a workaround by calling into Ruby for this:\r\n\r\n```ruby\r\nJavaEmbedUtils.invokeMethod(rubyRuntime, block, \"context=\", new Object[]{RubySymbol.newSymbol(rubyRuntime, newContext)}, Object.class);\r\n```\r\n\r\nbut a nicer way would probably be to have a `setContext` method on `Block`. (Also above approach seems to break in 1.6 because there is no `rubyRuntime` anymore, but I haven't looked into a replacement of that, yet.)"},"comment":{"url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/comments/209808369","html_url":"https://github.com/asciidoctor/asciidoctorj/issues/447#issuecomment-209808369","issue_url":"https://api.github.com/repos/asciidoctor/asciidoctorj/issues/447","id":209808369,"user":{"login":"robertpanzer","id":1163662,"avatar_url":"https://avatars.githubusercontent.com/u/1163662?v=3","gravatar_id":"","url":"https://api.github.com/users/robertpanzer","html_url":"https://github.com/robertpanzer","followers_url":"https://api.github.com/users/robertpanzer/followers","following_url":"https://api.github.com/users/robertpanzer/following{/other_user}","gists_url":"https://api.github.com/users/robertpanzer/gists{/gist_id}","starred_url":"https://api.github.com/users/robertpanzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertpanzer/subscriptions","organizations_url":"https://api.github.com/users/robertpanzer/orgs","repos_url":"https://api.github.com/users/robertpanzer/repos","events_url":"https://api.github.com/users/robertpanzer/events{/privacy}","received_events_url":"https://api.github.com/users/robertpanzer/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T07:39:24Z","updated_at":"2016-04-14T07:39:24Z","body":"Hi,\n\nthe current API assumes that you pass the context when creating a new block via one of the `Processor.create…()` methods.\n\nInvoking ruby methods directly on the blocks that you get passed to AsciidoctorJ will no longer work in 1.6.0 as these are no longer Ruby objects, but proxies managed by AsciidoctorJ that forward all calls to corresponding Asciidoctor Ruby objects.\n\nHaving said that you still can access the Ruby instance used by an Asciidoctor instance. But instead of being a singleton you have to pass the Asciidoctor instance:\n\n\tRuby ruby = JRubyRuntimeContext.get(asciidoctor);\n\nCheers\nRobert\n\n> Am 14.04.2016 um 09:31 schrieb ygra <notifications@github.com>:\n> \n> This doesn't seem to be exposed in AsciidoctorJ, although it exists in Asciidoctor.\n> \n> I currently have a custom block processor that will parse parts of its contents as normal blocks and then set the context of those blocks to use custom templates for them (instead of handling them as normal paragraphs). I'm currently using a workaround by calling into Ruby for this:\n> \n> JavaEmbedUtils.invokeMethod(rubyRuntime, block, \"context=\", new Object[]{RubySymbol.newSymbol(rubyRuntime, newContext)}, Object.class);\n> but a nicer way would probably be to have a setContext method on Block. (Also above approach seems to break in 1.6 because there is no rubyRuntime anymore, but I haven't looked into a replacement of that, yet.)\n> \n> —\n> You are receiving this because you are subscribed to this thread.\n> Reply to this email directly or view it on GitHub <https://github.com/asciidoctor/asciidoctorj/issues/447>\n\n"}}