Skip to content

Commit abde072

Browse files
committed
Merge pull request gazay#22 from Bushjumper/master
Resolve Issue gazay#19
2 parents 155950f + b722496 commit abde072

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ alert(customNamespace.yourHash)
126126
Now you can write your variables assign logic to templates with [Rabl](https://github.com/nesquena/rabl).
127127
The way of writing Rabl templates is very clearly described in their repo.
128128

129+
Add Rabl to your Gemfile
130+
131+
`Gemfile`
132+
133+
``` ruby
134+
gem 'rabl'
135+
```
136+
129137
Profit of using Rabl with gon:
130138

131139
1. You can clean your controllers now!

gon.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
1919
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
2020
s.require_paths = ["lib"]
2121
s.add_dependency "actionpack", '>= 2.3.0'
22-
s.add_dependency "rabl"
2322
s.add_dependency "json"
23+
s.add_development_dependency "rabl"
2424
s.add_development_dependency "rspec"
2525
s.add_development_dependency "jbuilder"
2626
end

lib/gon.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
require 'action_view'
55
require 'action_controller'
66
require 'gon/helpers'
7-
require 'gon/rabl'
7+
if defined?(Rabl)
8+
require 'gon/rabl'
9+
end
810
if RUBY_VERSION =~ /9/ && defined?(Jbuilder)
911
require 'gon/jbuilder'
1012
end
@@ -58,6 +60,9 @@ def set_variable(name, value)
5860
end
5961

6062
def rabl(view_path, options = {})
63+
if !defined?(Gon::Rabl)
64+
raise NoMethodError.new('You should define Rabl in your Gemfile')
65+
end
6166
rabl_data = Gon::Rabl.parse_rabl(view_path, options[:controller] ||
6267
@request_env['action_controller.instance'] ||
6368
@request_env['action_controller.rescue.response'].

0 commit comments

Comments
 (0)