handlebars_assets 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ module HandlebarsAssets
4
+ class CompilingTest < Test::Unit::TestCase
5
+
6
+ def teardown
7
+ HandlebarsAssets::Config.reset!
8
+ HandlebarsAssets::Handlebars.reset!
9
+ end
10
+
11
+ def test_custom_handlebars
12
+ source = "This is {{handlebars}}"
13
+
14
+ HandlebarsAssets::Config.compiler_path = File.expand_path '../../edge', __FILE__
15
+
16
+ compiled = Handlebars.precompile(source, HandlebarsAssets::Config.options)
17
+ assert_match /PRECOMPILE CALLED/, compiled
18
+ end
19
+
20
+ def test_patching_handlebars
21
+ source = "This is {{nested.handlebars}}"
22
+
23
+ HandlebarsAssets::Config.patch_path = File.expand_path '../../patch', __FILE__
24
+ HandlebarsAssets::Config.patch_files = ['patch.js']
25
+
26
+ compiled = Handlebars.precompile(source, HandlebarsAssets::Config.options)
27
+ assert_match /CALLED PATCH/, compiled
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ (function(window) {
2
+ var originalLookup = window.Handlebars.JavaScriptCompiler.prototype.nameLookup;
3
+
4
+ window.Handlebars.JavaScriptCompiler.prototype.nameLookup = function(parent, name, type) {
5
+ if (type === 'context') {
6
+ return '"CALLED PATCH"';
7
+ }
8
+ else {
9
+ return originalLookup(parent, name, type);
10
+ }
11
+ };
12
+ })(this);
@@ -61,6 +61,8 @@ module HandlebarsAssets
61
61
  @known_helpers = nil
62
62
  @known_helpers_only = nil
63
63
  @options = nil
64
+ @patch_files = nil
65
+ @patch_path = nil
64
66
  @path_prefix = nil
65
67
  @template_namespace = nil
66
68
  @ember = nil
@@ -73,6 +75,7 @@ module HandlebarsAssets
73
75
  def self.reset!
74
76
  @context = nil
75
77
  @source = nil
78
+ @patch_path = nil
76
79
  @path = nil
77
80
  @assets_path = nil
78
81
  end
metadata CHANGED
@@ -1,18 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
5
4
  prerelease:
5
+ version: 0.12.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Les Hill
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-15 00:00:00.000000000 Z
12
+ date: 2013-02-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: execjs
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.2.9
16
22
  requirement: !ruby/object:Gem::Requirement
17
23
  none: false
18
24
  requirements:
@@ -21,14 +27,14 @@ dependencies:
21
27
  version: 1.2.9
22
28
  type: :runtime
23
29
  prerelease: false
30
+ - !ruby/object:Gem::Dependency
31
+ name: tilt
24
32
  version_requirements: !ruby/object:Gem::Requirement
25
33
  none: false
26
34
  requirements:
27
35
  - - ! '>='
28
36
  - !ruby/object:Gem::Version
29
- version: 1.2.9
30
- - !ruby/object:Gem::Dependency
31
- name: tilt
37
+ version: '0'
32
38
  requirement: !ruby/object:Gem::Requirement
33
39
  none: false
34
40
  requirements:
@@ -37,14 +43,14 @@ dependencies:
37
43
  version: '0'
38
44
  type: :runtime
39
45
  prerelease: false
46
+ - !ruby/object:Gem::Dependency
47
+ name: sprockets
40
48
  version_requirements: !ruby/object:Gem::Requirement
41
49
  none: false
42
50
  requirements:
43
51
  - - ! '>='
44
52
  - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: sprockets
53
+ version: 2.0.3
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  none: false
50
56
  requirements:
@@ -53,14 +59,14 @@ dependencies:
53
59
  version: 2.0.3
54
60
  type: :runtime
55
61
  prerelease: false
62
+ - !ruby/object:Gem::Dependency
63
+ name: debugger
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
65
  none: false
58
66
  requirements:
59
67
  - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
- version: 2.0.3
62
- - !ruby/object:Gem::Dependency
63
- name: rake
69
+ version: '0'
64
70
  requirement: !ruby/object:Gem::Requirement
65
71
  none: false
66
72
  requirements:
@@ -69,14 +75,14 @@ dependencies:
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
78
+ - !ruby/object:Gem::Dependency
79
+ name: haml
72
80
  version_requirements: !ruby/object:Gem::Requirement
73
81
  none: false
74
82
  requirements:
75
83
  - - ! '>='
76
84
  - !ruby/object:Gem::Version
77
85
  version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: haml
80
86
  requirement: !ruby/object:Gem::Requirement
81
87
  none: false
82
88
  requirements:
@@ -85,14 +91,14 @@ dependencies:
85
91
  version: '0'
86
92
  type: :development
87
93
  prerelease: false
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
88
96
  version_requirements: !ruby/object:Gem::Requirement
89
97
  none: false
90
98
  requirements:
91
99
  - - ! '>='
92
100
  - !ruby/object:Gem::Version
93
101
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: slim
96
102
  requirement: !ruby/object:Gem::Requirement
97
103
  none: false
98
104
  requirements:
@@ -101,12 +107,22 @@ dependencies:
101
107
  version: '0'
102
108
  type: :development
103
109
  prerelease: false
110
+ - !ruby/object:Gem::Dependency
111
+ name: slim
104
112
  version_requirements: !ruby/object:Gem::Requirement
105
113
  none: false
106
114
  requirements:
107
115
  - - ! '>='
108
116
  - !ruby/object:Gem::Version
109
117
  version: '0'
118
+ requirement: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
110
126
  description: Compile Handlebars templates in the Rails asset pipeline.
111
127
  email:
112
128
  - leshill@gmail.com
@@ -130,10 +146,11 @@ files:
130
146
  - lib/handlebars_assets/tilt_handlebars.rb
131
147
  - lib/handlebars_assets/version.rb
132
148
  - test/edge/handlebars.js
149
+ - test/handlebars_assets/compiling_test.rb
133
150
  - test/handlebars_assets/hamlbars_test.rb
134
151
  - test/handlebars_assets/slimbars_test.rb
135
- - test/handlebars_assets/tilt_edge_test.rb
136
152
  - test/handlebars_assets/tilt_handlebars_test.rb
153
+ - test/patch/patch.js
137
154
  - test/test_helper.rb
138
155
  - vendor/assets/javascripts/handlebars.js
139
156
  - vendor/assets/javascripts/handlebars.runtime.js
@@ -157,14 +174,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
174
  version: '0'
158
175
  requirements: []
159
176
  rubyforge_project: handlebars_assets
160
- rubygems_version: 1.8.23
177
+ rubygems_version: 1.8.25
161
178
  signing_key:
162
179
  specification_version: 3
163
180
  summary: Compile Handlebars templates in the Rails asset pipeline.
164
181
  test_files:
165
182
  - test/edge/handlebars.js
183
+ - test/handlebars_assets/compiling_test.rb
166
184
  - test/handlebars_assets/hamlbars_test.rb
167
185
  - test/handlebars_assets/slimbars_test.rb
168
- - test/handlebars_assets/tilt_edge_test.rb
169
186
  - test/handlebars_assets/tilt_handlebars_test.rb
187
+ - test/patch/patch.js
170
188
  - test/test_helper.rb
@@ -1,26 +0,0 @@
1
- require 'test_helper'
2
-
3
- module HandlebarsAssets
4
- class TiltEdgeTest < Test::Unit::TestCase
5
- include SprocketsScope
6
- include CompilerSupport
7
-
8
- def teardown
9
- HandlebarsAssets::Config.reset!
10
- HandlebarsAssets::Handlebars.reset!
11
- end
12
-
13
- def test_edge_compile
14
- root = '/myapp/app/assets/templates'
15
- file = 'test_render.hbs'
16
- scope = make_scope root, file
17
- source = "This is {{handlebars}}"
18
-
19
- HandlebarsAssets::Config.compiler_path = File.expand_path '../../edge', __FILE__
20
-
21
- template = HandlebarsAssets::TiltHandlebars.new(scope.pathname.to_s) { source }
22
-
23
- assert_equal hbs_compiled('test_render', source), template.render(scope, {})
24
- end
25
- end
26
- end