Browse Source

Explicitly pass root false when rendering JSON in view (#127)

Closes #108
Jacob Burenstam 7 years ago
parent
commit
ea60b7cd85
1 changed files with 1 additions and 1 deletions
  1. 1 1
      app/helpers/blazer/base_helper.rb

+ 1 - 1
app/helpers/blazer/base_helper.rb

@@ -33,7 +33,7 @@ module Blazer
     end
     end
 
 
     def blazer_js_var(name, value)
     def blazer_js_var(name, value)
-      "var #{name} = #{blazer_json_escape(value.to_json)}".html_safe
+      "var #{name} = #{blazer_json_escape(value.to_json(root: false))};".html_safe
     end
     end
 
 
     JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003e', '<' => '\u003c', "\u2028" => '\u2028', "\u2029" => '\u2029' }
     JSON_ESCAPE = { '&' => '\u0026', '>' => '\u003e', '<' => '\u003c', "\u2028" => '\u2028', "\u2029" => '\u2029' }