Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to use jbuilder for views #124

Closed
mbajur opened this issue Apr 27, 2017 · 3 comments
Closed

Not able to use jbuilder for views #124

mbajur opened this issue Apr 27, 2017 · 3 comments
Assignees
Labels

Comments

@mbajur
Copy link

mbajur commented Apr 27, 2017

Hello,

I'm not sure if thats a fault of hanami-views or tilt-jbuilder, there is an issue opened for tilt-jbuilder here: anthonator/tilt-jbuilder#20 (without any response. So i'm gonna try in here)

Basically - i want to use jbuilder for templates rendering in my hanami 1.0 app. However, after adding jbuilder and tilt-jbuilder to my Gemfile, when trying to render .jbuilder template file, hanami throws:

Boot Error

Something went wrong while loading /app/config.ru

NameError: undefined local variable or method `binding' for #<Hanami::View::Rendering::Scope:0x00557d1ec162b8> Did you mean? binding

/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering/layout_scope.rb:221:in `method_missing'
/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering/scope.rb:73:in `method_missing'
/box/gems/tilt-jbuilder-0.7.1/lib/tilt/jbuilder.rb:93:in `block (2 levels) in evaluate'
/box/gems/tilt-jbuilder-0.7.1/lib/tilt/jbuilder.rb:93:in `instance_eval'
/box/gems/tilt-jbuilder-0.7.1/lib/tilt/jbuilder.rb:93:in `block in evaluate'
/box/gems/jbuilder-2.6.3/lib/jbuilder.rb:18:in `initialize'
/box/gems/tilt-jbuilder-0.7.1/lib/tilt/jbuilder.rb:8:in `initialize'
/box/gems/jbuilder-2.6.3/lib/jbuilder.rb:23:in `new'
/box/gems/jbuilder-2.6.3/lib/jbuilder.rb:23:in `encode'
/box/gems/tilt-jbuilder-0.7.1/lib/tilt/jbuilder.rb:92:in `evaluate'
/box/gems/tilt-2.0.7/lib/tilt/template.rb:109:in `render'
/box/gems/hanami-view-1.0.0/lib/hanami/view/template.rb:41:in `render'
/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering.rb:139:in `rendered'
/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering.rb:153:in `layout'
/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering.rb:107:in `render'
/box/gems/hanami-view-1.0.0/lib/hanami/view/rendering.rb:258:in `render'
/box/gems/hanami-1.0.0/lib/hanami/rendering_policy.rb:56:in `_render_action'
/box/gems/hanami-1.0.0/lib/hanami/rendering_policy.rb:48:in `_render'
/box/gems/hanami-1.0.0/lib/hanami/rendering_policy.rb:38:in `render'
/box/gems/hanami-1.0.0/lib/hanami/application.rb:169:in `call'
/usr/local/lib/ruby/2.3.0/delegate.rb:83:in `method_missing'
/box/gems/http_router-0.11.2/lib/http_router.rb:193:in `process_destination_path'
(eval):18:in `call'
/box/gems/http_router-0.11.2/lib/http_router.rb:288:in `raw_call'
/box/gems/hanami-router-1.0.0/lib/hanami/routing/http_router.rb:156:in `raw_call'
/box/gems/http_router-0.11.2/lib/http_router.rb:142:in `call'
/box/gems/hanami-router-1.0.0/lib/hanami/router.rb:1016:in `call'
/box/gems/rack-2.0.1/lib/rack/method_override.rb:22:in `call'
/box/gems/rack-2.0.1/lib/rack/content_length.rb:15:in `call'
/box/gems/rack-2.0.1/lib/rack/common_logger.rb:33:in `call'
/box/gems/rack-2.0.1/lib/rack/builder.rb:153:in `call'
/box/gems/hanami-1.0.0/lib/hanami/app.rb:42:in `call'
/box/gems/shotgun-0.9.2/lib/shotgun/loader.rb:86:in `proceed_as_child'
/box/gems/shotgun-0.9.2/lib/shotgun/loader.rb:31:in `call!'
/box/gems/shotgun-0.9.2/lib/shotgun/loader.rb:18:in `call'
/box/gems/hanami-1.0.0/lib/hanami/assets/static.rb:49:in `call'
/box/gems/rack-2.0.1/lib/rack/lint.rb:49:in `_call'
/box/gems/rack-2.0.1/lib/rack/lint.rb:37:in `call'
/box/gems/rack-2.0.1/lib/rack/show_exceptions.rb:23:in `call'
/box/gems/rack-2.0.1/lib/rack/handler/webrick.rb:86:in `service'
/usr/local/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
/usr/local/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
/usr/local/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'

Thanks in advance for any help!

@jodosha
Copy link
Member

jodosha commented Apr 27, 2017

@mbajur Hi, I'm sorry about this problem. Can you please add here a few details:

  1. The path to the template (eg. apps/web/books/show.json.jbuilder)
  2. The contents of the template
  3. An example of the corresponding view (eg the code of Web::Views::Books::Show)

That would be helpful to understand what's going on.

@mbajur
Copy link
Author

mbajur commented Apr 27, 2017

Sure thing!

  1. It's apps/api/templates/v1/events/index.json.jbuilder
  2. Im not sure if sending it is worth anything cause it happens no matter if the file is empty or has any contents. But, here you go: https://gist.github.com/mbajur/0ce7553707a8a56052f4bd5f4b8e8653#file-index-json-jbuilder
  3. The view is a bare file created by generator: https://gist.github.com/mbajur/0ce7553707a8a56052f4bd5f4b8e8653#file-the-view

Thanks!

@jodosha
Copy link
Member

jodosha commented Aug 1, 2017

@mbajur I opened a PR for tilt-jbuilder, to make it compatible with BasicObject and by consequence with Hanami.

Please check it: anthonator/tilt-jbuilder#21

@jodosha jodosha closed this as completed Aug 1, 2017
@jodosha jodosha self-assigned this Aug 1, 2017
@jodosha jodosha added the invalid label Aug 1, 2017
timriley added a commit that referenced this issue Mar 15, 2020
…ookup

Prevent needless partial lookup in `<template name>/shared`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants