Skip to content
Browse files

Handle the case where there are no included scripts

  • Loading branch information...
1 parent 47a62f3 commit 6934df95f724b666fc986ed7104d833e96cbb692 @ArthurN committed Jul 23, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/isotope/isotope.rb
View
5 lib/isotope/isotope.rb
@@ -38,8 +38,11 @@ def self.render_partial(view_file, options = {})
isotope_file_path = File.join(File.dirname(__FILE__), "isotope.js")
view_file_content = template_file_content(view_file)
+
+ initial_script = included_scripts_source || ""
+ initial_script += IO.read(isotope_file_path)
- context = ExecJS.compile(included_scripts_source + " " + IO.read(isotope_file_path))
+ context = ExecJS.compile(initial_script)
script = "Isotope(#{view_file_content.to_json}, #{options[:locals].to_json})"
output = context.eval(script)

1 comment on commit 6934df9

@elado
elado commented on 6934df9 Jul 23, 2011

Thanks

Two fixes needed:

  1. Add a semicolon after included scripts
  2. Concatenate strings with << instead of +=

    initial_script = included_scripts_source ? included_scripts_source + ";" : ""
    initial_script << IO.read(isotope_file_path)

I'll merge after that. Thanks so much for contributing!

Please sign in to comment.
Something went wrong with that request. Please try again.