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 +4 -4
- data/CHANGELOG.md +5 -0
- data/handlebars_assets.gemspec +1 -1
- data/lib/handlebars_assets/config.rb +10 -1
- data/lib/handlebars_assets/handlebars_template.rb +8 -1
- data/lib/handlebars_assets/version.rb +1 -1
- data/test/handlebars_assets/tilt_handlebars_test.rb +25 -0
- data/test/test_helper.rb +1 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdaf8b259b43089237a16471ec5b515ede063275
|
4
|
+
data.tar.gz: 1bd29b0c391be103666f66bcf1e3a44b29c21146
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fbac5cbefececb37f4c1603cd99ad79533de8ff42e07df143816165f9f79fc4459b91eaa5b1f965432db89dcdd49dc0bcc6a842d3c082689407db57c1a5f7c6
|
7
|
+
data.tar.gz: 15032641cb9a08431e8fad9680c71f9bf70df9281ebdc82c395a9eabd627f719f892d27de5d80a39e1f3df2091ab8323aeae3ff1590dfd8586a4bed24c9b804c
|
data/CHANGELOG.md
CHANGED
data/handlebars_assets.gemspec
CHANGED
@@ -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", "
|
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
|
@@ -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'
|
data/test/test_helper.rb
CHANGED
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.
|
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-
|
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:
|
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:
|
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
|