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

empty :javascript section causes issues #947

Closed
dminnick opened this issue Aug 7, 2017 · 6 comments
Closed

empty :javascript section causes issues #947

dminnick opened this issue Aug 7, 2017 · 6 comments

Comments

@dminnick
Copy link

dminnick commented Aug 7, 2017

On 5.0.2, the presence of an empty :javascript section at the bottom of a HAML file causes the following stack error. My apologies for not digging into the issue more, will try to provide more information later.

= render "#{@listing.product_type_key.pluralize}/form_fields",
product: @Product, f: product_form, listing_form: f

undefined method `rstrip' for nil:NilClass

haml (5.0.2) lib/haml/filters.rb:216:in render_with_options' haml (5.0.2) lib/haml/filters.rb:185:in block in compile'
haml (5.0.2) lib/haml/filters.rb:163:in instance_eval' haml (5.0.2) lib/haml/filters.rb:163:in compile'
haml (5.0.2) lib/haml/filters.rb:142:in internal_compile' haml (5.0.2) lib/haml/compiler.rb:180:in compile_filter'
haml (5.0.2) lib/haml/compiler.rb:29:in compile' haml (5.0.2) lib/haml/compiler.rb:31:in block (2 levels) in compile'
haml (5.0.2) lib/haml/compiler.rb:31:in each' haml (5.0.2) lib/haml/compiler.rb:31:in block in compile'
haml (5.0.2) lib/haml/compiler.rb:41:in compile_root' haml (5.0.2) lib/haml/compiler.rb:31:in compile'
haml (5.0.2) lib/haml/compiler.rb:22:in call' temple (0.8.0) lib/temple/engine.rb:50:in block in call'
temple (0.8.0) lib/temple/engine.rb:50:in each' temple (0.8.0) lib/temple/engine.rb:50:in inject'
temple (0.8.0) lib/temple/engine.rb:50:in call' haml (5.0.2) lib/haml/temple_engine.rb:41:in compile'
haml (5.0.2) lib/haml/engine.rb:61:in initialize' haml (5.0.2) lib/haml/plugin.rb:16:in new'
haml (5.0.2) lib/haml/plugin.rb:16:in compile' haml (5.0.2) lib/haml/plugin.rb:23:in call'
actionview (5.0.2) lib/action_view/template.rb:284:in compile' actionview (5.0.2) lib/action_view/template.rb:259:in block (2 levels) in compile!'
activesupport (5.0.2) lib/active_support/notifications.rb:166:in instrument' actionview (5.0.2) lib/action_view/template.rb:356:in instrument'
actionview (5.0.2) lib/action_view/template.rb:258:in block in compile!' actionview (5.0.2) lib/action_view/template.rb:246:in synchronize'
actionview (5.0.2) lib/action_view/template.rb:246:in compile!' actionview (5.0.2) lib/action_view/template.rb:158:in block in render'
activesupport (5.0.2) lib/active_support/notifications.rb:166:in instrument' actionview (5.0.2) lib/action_view/template.rb:354:in instrument'
actionview (5.0.2) lib/action_view/template.rb:157:in render' actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:343:in render_partial'
actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:311:in block in render' actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:42:in block in instrument'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in block in instrument' activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in instrument'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in instrument' actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:41:in instrument'
actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:310:in render' actionview (5.0.2) lib/action_view/renderer/renderer.rb:47:in render_partial'
actionview (5.0.2) lib/action_view/helpers/rendering_helper.rb:35:in render' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:12:in block in render'
haml (5.0.2) lib/haml/helpers.rb:92:in non_haml' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:12:in render'
app/views/listings/_form_fields.html.haml:52:in block in _app_views_listings__form_fields_html_haml__2889938891238024525_70357942257620' haml (5.0.2) lib/haml/helpers.rb:382:in block in capture_haml'
haml (5.0.2) lib/haml/helpers.rb:667:in with_haml_buffer' haml (5.0.2) lib/haml/helpers.rb:378:in capture_haml'
haml (5.0.2) lib/haml/helpers/xss_mods.rb:62:in capture_haml_with_haml_xss' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:45:in capture_with_haml'
actionview (5.0.2) lib/action_view/helpers/form_helper.rb:1927:in block in fields_for_nested_model' actionview (5.0.2) lib/action_view/helpers/capture_helper.rb:39:in block in capture'
actionview (5.0.2) lib/action_view/helpers/capture_helper.rb:203:in with_output_buffer' haml (5.0.2) lib/haml/helpers/action_view_xss_mods.rb:6:in with_output_buffer_with_haml_xss'
actionview (5.0.2) lib/action_view/helpers/capture_helper.rb:39:in capture' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:47:in capture_with_haml'
actionview (5.0.2) lib/action_view/helpers/form_helper.rb:720:in fields_for' actionview (5.0.2) lib/action_view/helpers/form_helper.rb:1926:in fields_for_nested_model'
actionview (5.0.2) lib/action_view/helpers/form_helper.rb:1916:in fields_for_with_nested_attributes' actionview (5.0.2) lib/action_view/helpers/form_helper.rb:1561:in fields_for'
app/views/listings/_form_fields.html.haml:49:in _app_views_listings__form_fields_html_haml__2889938891238024525_70357942257620' actionview (5.0.2) lib/action_view/template.rb:159:in block in render'
activesupport (5.0.2) lib/active_support/notifications.rb:166:in instrument' actionview (5.0.2) lib/action_view/template.rb:354:in instrument'
actionview (5.0.2) lib/action_view/template.rb:157:in render' actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:343:in render_partial'
actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:311:in block in render' actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:42:in block in instrument'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in block in instrument' activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in instrument'
activesupport (5.0.2) lib/active_support/notifications.rb:164:in instrument' actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:41:in instrument'
actionview (5.0.2) lib/action_view/renderer/partial_renderer.rb:310:in render' actionview (5.0.2) lib/action_view/renderer/renderer.rb:47:in render_partial'
actionview (5.0.2) lib/action_view/helpers/rendering_helper.rb:35:in render' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:12:in block in render'
haml (5.0.2) lib/haml/helpers.rb:92:in non_haml' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:12:in render'
app/views/listings/new.html.haml:12:in block in _app_views_listings_new_html_haml__4475820584130041952_70358220264160' haml (5.0.2) lib/haml/helpers.rb:382:in block in capture_haml'
haml (5.0.2) lib/haml/helpers.rb:667:in with_haml_buffer' haml (5.0.2) lib/haml/helpers.rb:378:in capture_haml'
haml (5.0.2) lib/haml/helpers/xss_mods.rb:62:in capture_haml_with_haml_xss' haml (5.0.2) lib/haml/helpers/action_view_mods.rb:45:in capture_with_haml'
actionview (5.0.2) lib/action_view/helpers/form_helper.rb:450:in form_for' haml (5.0.2) lib/haml/helpers/action_view_xss_mods.rb:29:in form_for_with_haml_xss'
app/views/listings/new.html.haml:10:in _app_views_listings_new_html_haml__4475820584130041952_70358220264160' actionview (5.0.2) lib/action_view/template.rb:159:in block in render'
activesupport (5.0.2) lib/active_support/notifications.rb:166:in instrument' actionview (5.0.2) lib/action_view/template.rb:354:in instrument'
actionview (5.0.2) lib/action_view/template.rb:157:in render' actionview (5.0.2) lib/action_view/renderer/template_renderer.rb:54:in block (2 levels) in render_template'
actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:42:in block in instrument' activesupport (5.0.2) lib/active_support/notifications.rb:164:in block in instrument'
activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (5.0.2) lib/active_support/notifications.rb:164:in instrument'
actionview (5.0.2) lib/action_view/renderer/abstract_renderer.rb:41:in instrument' actionview (5.0.2) lib/action_view/renderer/template_renderer.rb:53:in block in render_template'
actionview (5.0.2) lib/action_view/renderer/template_renderer.rb:61:in render_with_layout' actionview (5.0.2) lib/action_view/renderer/template_renderer.rb:52:in render_template'
actionview (5.0.2) lib/action_view/renderer/template_renderer.rb:14:in render' actionview (5.0.2) lib/action_view/renderer/renderer.rb:42:in render_template'
actionview (5.0.2) lib/action_view/renderer/renderer.rb:23:in render' actionview (5.0.2) lib/action_view/rendering.rb:104:in _render_template'
actionpack (5.0.2) lib/action_controller/metal/streaming.rb:217:in _render_template' actionview (5.0.2) lib/action_view/rendering.rb:83:in render_to_body'
actionpack (5.0.2) lib/action_controller/metal/rendering.rb:52:in render_to_body' actionpack (5.0.2) lib/action_controller/metal/renderers.rb:142:in render_to_body'
actionpack (5.0.2) lib/abstract_controller/rendering.rb:26:in render' actionpack (5.0.2) lib/action_controller/metal/rendering.rb:36:in render'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:44:in block (2 levels) in render' activesupport (5.0.2) lib/active_support/core_ext/benchmark.rb:12:in block in ms'
/home/jbeyer/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/benchmark.rb:308:in realtime' activesupport (5.0.2) lib/active_support/core_ext/benchmark.rb:12:in ms'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:44:in block in render' actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:87:in cleanup_view_runtime'
activerecord (5.0.2) lib/active_record/railties/controller_runtime.rb:25:in cleanup_view_runtime' elasticsearch-rails (0.1.9) lib/elasticsearch/rails/instrumentation/controller_runtime.rb:20:in cleanup_view_runtime'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:43:in render' actionpack (5.0.2) lib/action_controller/metal/implicit_render.rb:36:in default_render'
actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in block in send_action' actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in tap'
actionpack (5.0.2) lib/action_controller/metal/basic_implicit_render.rb:4:in send_action' actionpack (5.0.2) lib/abstract_controller/base.rb:188:in process_action'
actionpack (5.0.2) lib/action_controller/metal/rendering.rb:30:in process_action' actionpack (5.0.2) lib/abstract_controller/callbacks.rb:20:in block in process_action'
activesupport (5.0.2) lib/active_support/callbacks.rb:126:in call' activesupport (5.0.2) lib/active_support/callbacks.rb:506:in block (2 levels) in compile'
activesupport (5.0.2) lib/active_support/callbacks.rb:455:in call' activesupport (5.0.2) lib/active_support/callbacks.rb:101:in run_callbacks'
activesupport (5.0.2) lib/active_support/callbacks.rb:750:in _run_process_action_callbacks' activesupport (5.0.2) lib/active_support/callbacks.rb:90:in run_callbacks'
actionpack (5.0.2) lib/abstract_controller/callbacks.rb:19:in process_action' actionpack (5.0.2) lib/action_controller/metal/rescue.rb:20:in process_action'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:32:in block in process_action' activesupport (5.0.2) lib/active_support/notifications.rb:164:in block in instrument'
activesupport (5.0.2) lib/active_support/notifications/instrumenter.rb:21:in instrument' activesupport (5.0.2) lib/active_support/notifications.rb:164:in instrument'
actionpack (5.0.2) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (5.0.2) lib/action_controller/metal/params_wrapper.rb:248:in process_action'
activerecord (5.0.2) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (5.0.2) lib/abstract_controller/base.rb:126:in process'
actionview (5.0.2) lib/action_view/rendering.rb:30:in process' actionpack (5.0.2) lib/action_controller/metal.rb:190:in dispatch'
actionpack (5.0.2) lib/action_controller/metal.rb:262:in dispatch' actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:50:in dispatch'
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:32:in serve' actionpack (5.0.2) lib/action_dispatch/journey/router.rb:39:in block in serve'
actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in each' actionpack (5.0.2) lib/action_dispatch/journey/router.rb:26:in serve'
actionpack (5.0.2) lib/action_dispatch/routing/route_set.rb:725:in call' warden (1.2.7) lib/warden/manager.rb:36:in block in call'
warden (1.2.7) lib/warden/manager.rb:35:in catch' warden (1.2.7) lib/warden/manager.rb:35:in call'
rack (2.0.2) lib/rack/etag.rb:25:in call' rack (2.0.2) lib/rack/conditional_get.rb:25:in call'
rack (2.0.2) lib/rack/head.rb:12:in call' rack (2.0.2) lib/rack/session/abstract/id.rb:232:in context'
rack (2.0.2) lib/rack/session/abstract/id.rb:226:in call' actionpack (5.0.2) lib/action_dispatch/middleware/cookies.rb:613:in call'
activerecord (5.0.2) lib/active_record/migration.rb:553:in call' actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:38:in block in call'
activesupport (5.0.2) lib/active_support/callbacks.rb:97:in __run_callbacks__' activesupport (5.0.2) lib/active_support/callbacks.rb:750:in _run_call_callbacks'
activesupport (5.0.2) lib/active_support/callbacks.rb:90:in run_callbacks' actionpack (5.0.2) lib/action_dispatch/middleware/callbacks.rb:36:in call'
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in call' actionpack (5.0.2) lib/action_dispatch/middleware/remote_ip.rb:79:in call'
rollbar (2.14.1) lib/rollbar/middleware/rails/rollbar.rb:24:in block in call' rollbar (2.14.1) lib/rollbar.rb:145:in scoped'
rollbar (2.14.1) lib/rollbar/middleware/rails/rollbar.rb:22:in call' actionpack (5.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in call'
rollbar (2.14.1) lib/rollbar/middleware/rails/show_exceptions.rb:22:in call_with_rollbar' actionpack (5.0.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in call'
railties (5.0.2) lib/rails/rack/logger.rb:36:in call_app' railties (5.0.2) lib/rails/rack/logger.rb:24:in block in call'
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in block in tagged' activesupport (5.0.2) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (5.0.2) lib/active_support/tagged_logging.rb:69:in tagged' railties (5.0.2) lib/rails/rack/logger.rb:24:in call'
actionpack (5.0.2) lib/action_dispatch/middleware/request_id.rb:24:in call' rack (2.0.2) lib/rack/method_override.rb:22:in call'
rack (2.0.2) lib/rack/runtime.rb:22:in call' activesupport (5.0.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call'
actionpack (5.0.2) lib/action_dispatch/middleware/executor.rb:12:in call' actionpack (5.0.2) lib/action_dispatch/middleware/static.rb:136:in call'
rack (2.0.2) lib/rack/sendfile.rb:111:in call' railties (5.0.2) lib/rails/engine.rb:522:in call'
puma (3.8.2) lib/puma/configuration.rb:224:in call' puma (3.8.2) lib/puma/server.rb:600:in handle_request'
puma (3.8.2) lib/puma/server.rb:435:in process_client' puma (3.8.2) lib/puma/server.rb:299:in block in run'
puma (3.8.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

@cavoixanha
Copy link

I fix by override module Javascript, If It's raise errors on study case another please notify for me!

Haml::Filters::Javascript.module_eval do
  def render_with_options(text, options)
    indent = options[:cdata] ? '    ' : '  ' # 4 or 2 spaces
    if options[:format] == :html5
      type = ''
    else
      type = " type=#{options[:attr_wrapper]}text/javascript#{options[:attr_wrapper]}"
    end

    if text.nil?
      text = ''
    else
      text = text.rstrip
    end
    text.gsub!("\n", "\n#{indent}")

    %!<script#{type}>\n#{"  //<![CDATA[\n" if options[:cdata]}#{indent}#{text}\n#{"  //]]>\n" if options[:cdata]}</script>!
  end
end

@golovlevviktor
Copy link

On version 5.0.3 I also have this error(

@joevandyk
Copy link

5.0.4 as well.

@ngocbv
Copy link

ngocbv commented Nov 7, 2017

@cavoixanha hi, do you know root problem and why text is nil when upgrading rails to 5?

@k0kubun k0kubun mentioned this issue Feb 19, 2018
@composerinteralia
Copy link

This looks like a duplicate of #985 which was fixed with #986

@k0kubun
Copy link
Member

k0kubun commented Jun 21, 2020

Yeah right. Please try the latest Haml.

@k0kubun k0kubun closed this as completed Jun 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants