Skip to content

Commit 9bd3d78

Browse files
committed
initialize option to show always window.gon = {};
1 parent 725e14d commit 9bd3d78

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/gon/helpers.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def include_gon(options = {})
1313
elsif Gon.global.all_variables.present?
1414
Gon.clear
1515
Gon::Base.render_data(options)
16+
elsif options[:init].present?
17+
Gon::Base.render_data(options)
1618
else
1719
""
1820
end

spec/gon/basic_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
'gon.int=1;'
8080
end
8181

82+
83+
it 'outputs correct js without variables, without tag and gon init' do
84+
@base.include_gon(need_tag: false, init: true).should == \
85+
'window.gon = {};'
86+
end
87+
8288
end
8389

8490
it 'returns exception if try to set public method as variable' do

0 commit comments

Comments
 (0)