handlebars_assets 0.20.1 → 0.20.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4384395fc4ee4197451cbc31b94b7dedbb4c0b06
4
- data.tar.gz: c2d75643bbb557ff663e6193bfe22dc1e97e468c
3
+ metadata.gz: cdaf8b259b43089237a16471ec5b515ede063275
4
+ data.tar.gz: 1bd29b0c391be103666f66bcf1e3a44b29c21146
5
5
  SHA512:
6
- metadata.gz: d70f5ee4ab2d923c0b3ba05b537dc131e75f8bf1845d3549ddfa6f70747b38897975b0e93313ea1071c4eb125cbe4e7f78790a0516fee937965e09e80f38706d
7
- data.tar.gz: fbf7c27945ca12331c2bf023408c6ca13ab1d0aa6f7f96c785f2ab1fee3d8a8dea594c213eed3bc111a6cc362877219d590a1d3679e47a6a30b9dd9ab7e21715
6
+ metadata.gz: 4fbac5cbefececb37f4c1603cd99ad79533de8ff42e07df143816165f9f79fc4459b91eaa5b1f965432db89dcdd49dc0bcc6a842d3c082689407db57c1a5f7c6
7
+ data.tar.gz: 15032641cb9a08431e8fad9680c71f9bf70df9281ebdc82c395a9eabd627f719f892d27de5d80a39e1f3df2091ab8323aeae3ff1590dfd8586a4bed24c9b804c
@@ -1,3 +1,8 @@
1
+ ## 0.20.2 (2015-02-24)
2
+
3
+ * Relax Sprockets Dependencies - @rounders
4
+ * Add option to CHOMP underscores on partials - @GreyKn
5
+
1
6
  ## 0.20.1 (2015-02-24)
2
7
 
3
8
  * Actually revert to native HB.js
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_runtime_dependency "execjs", "~> 2.0"
23
23
  s.add_runtime_dependency "tilt", "~> 1.2"
24
24
  s.add_runtime_dependency "multi_json", "~> 1.0"
25
- s.add_runtime_dependency "sprockets", "~> 2.0"
25
+ s.add_runtime_dependency "sprockets", ">= 2.0.0", "< 4.0"
26
26
 
27
27
  s.add_development_dependency "minitest", '~> 5.5'
28
28
  s.add_development_dependency "haml", '~> 4.0'
@@ -11,7 +11,8 @@ module HandlebarsAssets
11
11
  :patch_files, :patch_path, :path_prefix, :slim_options, :template_namespace,
12
12
  :precompile, :haml_enabled, :slim_enabled,
13
13
  :handlebars_extensions, :hamlbars_extensions, :slimbars_extensions,
14
- :amd, :handlebars_amd_path, :amd_with_template_namespace
14
+ :amd, :handlebars_amd_path, :amd_with_template_namespace,
15
+ :chomp_underscore_for_partials
15
16
 
16
17
  def compiler
17
18
  @compiler || 'handlebars.js'
@@ -125,6 +126,14 @@ module HandlebarsAssets
125
126
  @handlebars_amd_path || 'handlebars'
126
127
  end
127
128
 
129
+ # Indicate if leading underscore should be allowed
130
+ # when creating partial definition.
131
+ # Allows compatibility with handlebars-rails
132
+ # https://github.com/cowboyd/handlebars-rails/blob/f73a2d11df8aa2c21d335b8f04a8c5b59ae6a790/lib/handlebars-rails/tilt.rb#L18
133
+ def chomp_underscore_for_partials?
134
+ @chomp_underscore_for_partials || false
135
+ end
136
+
128
137
  private
129
138
 
130
139
  def generate_known_helpers_hash
@@ -190,7 +190,14 @@ module HandlebarsAssets
190
190
  private
191
191
 
192
192
  def relative_path
193
- @full_path.match(/.*#{HandlebarsAssets::Config.path_prefix}\/((.*\/)*([^.]*)).*$/)[1]
193
+ path = @full_path.match(/.*#{HandlebarsAssets::Config.path_prefix}\/((.*\/)*([^.]*)).*$/)[1]
194
+ if is_partial? && ::HandlebarsAssets::Config.chomp_underscore_for_partials?
195
+ #handle case if partial is in root level of template folder
196
+ path.gsub!(%r~^_~, '')
197
+ #handle case if partial is in a subfolder within the template folder
198
+ path.gsub!(%r~/_~, '/')
199
+ end
200
+ path
194
201
  end
195
202
 
196
203
  def template_name
@@ -1,3 +1,3 @@
1
1
  module HandlebarsAssets
2
- VERSION = "0.20.1"
2
+ VERSION = "0.20.2"
3
3
  end
@@ -74,6 +74,31 @@ module HandlebarsAssets
74
74
  assert_equal hbs_compiled_partial('some/thing/_test_underscore', source), template2.render(scope2, {})
75
75
  end
76
76
 
77
+ def test_chomped_underscore_partials
78
+ assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, false
79
+
80
+ HandlebarsAssets::Config.chomp_underscore_for_partials = true
81
+ assert_equal HandlebarsAssets::Config.chomp_underscore_for_partials?, true
82
+
83
+ root = '/myapp/app/assets/javascripts'
84
+ file1 = 'app/templates/_test_underscore.hbs'
85
+ scope1 = make_scope root, file1
86
+ file2 = 'app/templates/some/thing/_test_underscore.hbs'
87
+ scope2 = make_scope root, file2
88
+ source = "This is {{handlebars}}"
89
+
90
+ HandlebarsAssets::Config.path_prefix = 'app/templates'
91
+
92
+ template1 = HandlebarsAssets::HandlebarsTemplate.new(scope1.pathname.to_s) { source }
93
+
94
+ assert_equal hbs_compiled_partial('test_underscore', source), template1.render(scope1, {})
95
+
96
+ template2 = HandlebarsAssets::HandlebarsTemplate.new(scope2.pathname.to_s) { source }
97
+
98
+ assert_equal hbs_compiled_partial('some/thing/test_underscore', source), template2.render(scope2, {})
99
+
100
+ end
101
+
77
102
  def test_without_known_helpers_opt
78
103
  root = '/myapp/app/assets/templates'
79
104
  file = 'test_without_known.hbs'
@@ -55,6 +55,7 @@ module HandlebarsAssets
55
55
  extend self
56
56
 
57
57
  def reset!
58
+ @chomp_underscore_for_partials = nil
58
59
  @compiler = nil
59
60
  @compiler_path = nil
60
61
  @haml_options = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handlebars_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.1
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-25 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -56,16 +56,22 @@ dependencies:
56
56
  name: sprockets
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: 2.0.0
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '4.0'
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
- - - "~>"
69
+ - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: '2.0'
71
+ version: 2.0.0
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '4.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: minitest
71
77
  requirement: !ruby/object:Gem::Requirement