erubis_for_rails23 0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -20,6 +20,8 @@ Or install it yourself as:
20
20
 
21
21
  Just install it and require it in your Rails 2.3 project
22
22
 
23
+ You could add `ERB_ENGINE = Erubis::FastEruby` to `config/environment.rb` if you want to switch to `FastEruby`
24
+
23
25
  ## Contributing
24
26
 
25
27
  1. Fork it
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'erubis_for_rails23'
3
- spec.version = '0.1'
3
+ spec.version = '0.1.1'
4
4
  spec.authors = ['Bachue Zhou']
5
5
  spec.email = ['bachue.shu@gmail.com']
6
6
  spec.description = %q{A simple gem which can resolve some compatibility issues when using Erubis in Rails 2.3}
@@ -1,20 +1,24 @@
1
1
  require 'erubis'
2
2
  require 'erb'
3
3
 
4
- util = ERB::Util
4
+ ERB_ENGINE = Erubis::Eruby unless defined?(ERB_ENGINE)
5
5
 
6
- Object.send :remove_const, :ERB
7
- ERB = Erubis::Eruby
8
- ERB::Util = util
6
+ if ERB_ENGINE != ERB
7
+ util = ERB::Util
9
8
 
10
- class Erubis::Eruby # to be compatible with ERB constructor
11
- def initialize(input = nil, *args)
12
- if args.size.zero? || args.first.is_a?(Hash)
13
- super
14
- else
15
- trim = args[1] == '-'
16
- bufvar = args[2]
17
- super input, :trim => trim, :bufvar => bufvar
9
+ Object.send :remove_const, :ERB
10
+ ERB = ERB_ENGINE
11
+ ERB::Util = util
12
+
13
+ class Erubis::Eruby # to be compatible with ERB constructor
14
+ def initialize(input = nil, *args)
15
+ if args.size.zero? || args.first.is_a?(Hash)
16
+ super
17
+ else
18
+ trim = args[1] == '-'
19
+ bufvar = args[2]
20
+ super input, :trim => trim, :bufvar => bufvar
21
+ end
18
22
  end
19
23
  end
20
24
  end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- version: "0.1"
8
+ - 1
9
+ version: 0.1.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Bachue Zhou