Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added the ability to supress jsvars by using *jsvars(false)* so anyth…

…ing set in a filter or whereever will not go out (mainly or partials)
  • Loading branch information...
commit 28593f1371677175d76cdbfd71ca70499a410f2c 1 parent 0d7de0f
@ejschmitt authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 lib/jsvars.rb
View
19 lib/jsvars.rb
@@ -6,14 +6,19 @@ def self.included(base)
end
module InstanceMethods
- def jsvars
- @jsvars ||= Hash.new
- end
+ def jsvars(option = nil)
+ @jsvars ||= Hash.new
+ if option == false
+ @vars_off = true
+ end
+ @jsvars
+ end
def include_jsvars
jsvars = @jsvars
name = 'jsvars'
return unless jsvars && response && response.content_type && response.content_type[/html|fbml/i]
+ return if @vars_off
js_assignments = []
jsvars.each do |variable, value|
js_assignments <<
@@ -67,8 +72,12 @@ def include_jsvars
#{ js_assignments.join }
</script>
<!-- end #{ name } plugin code -->"
- index = response.body.index(/<\/body>/i) || -1
- response.body.insert index, added_script
+
+ if index = response.body.index /<\/body>/i
+ response.body.insert index, added_script
+ else
+ response.body << added_script
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.