JSON::GeneratorError after moving from 1.4.0 to 2.0.x

Open
#29 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
coffeescript, ruby
Domain
tooling

Research direction

Start with the failing app/views/admin/stats/stats.js.coffee template and trace compilation through coffee-script/lib/coffee_script.rb and execjs (2.0.0) lib/execjs/external_runtime.rb. Compare the behavior with ExecJS 1.4.0 using the shown template and error, then determine the supported input and output behavior for this case.

Written by the indexing model from the issue text.

Description

I'm just moving a previous issue from the old repo here. Is there a way of doing this using ExecJS > 1.4.0?

Using this in a js.coffee erb template

$("#stats").replaceWith("<%= escape_javascript(render @template) %>")
now causes this error

JSON::GeneratorError - only generation of JSON objects or arrays allowed:
  /Users/Nick/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/json/common.rb:216:in `generate'
  /Users/Nick/.rbenv/versions/1.9.3-p327/lib/ruby/1.9.1/json/common.rb:345:in `dump'
  execjs (2.0.0) lib/execjs/external_runtime.rb:19:in `eval'
  execjs (2.0.0) lib/execjs/external_runtime.rb:33:in `call'
  coffee-script (2.2.0) lib/coffee_script.rb:57:in `compile'
  app/views/admin/stats/stats.js.coffee:1:in `_app_views_admin_stats_stats_js_coffee___1014294459951170846_70216695895960'
This worked just fine with 1.4.0 Should a different approach now be used?
Dominant language
Ruby
Stars
581
Forks
285
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rails/execjs

All issues in rails/execjs

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.