ember-handlebars-template 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16ecf940925fea527d60bf6f1589a49058f99a5c
4
- data.tar.gz: f5d12ab8225fa4297ee82250a4a5da780c2ea42d
3
+ metadata.gz: 77319b803ef0bb86af75d3a3bf0b99995c7be108
4
+ data.tar.gz: 6e4ab11bd2addd353bf1e68f6373fef17c4b90f5
5
5
  SHA512:
6
- metadata.gz: 9bf29f8634294e12fe36466edb5bcae1cc5356c66e9770f7545ab4971e12d06ce312eb5ef4c742f1401f5b7c5ffe4d9eb5446f4c1adcd4f1ab5e5fd5ced4c250
7
- data.tar.gz: 704dda831fb06fb00c28c358abd9e22dca6c069596fd48533d1af5b5698a9c42aea2aadf8a1399969ec0d8c617c5621b17f6eb5bf4a0f7be97aa1ebf5cf1c662
6
+ metadata.gz: 510f0f567b9ce63fafb3fc9c1c90ea1913dc9586d3e25ab3d7e7ca38a6ee0caa2846bd4237c4a5af51af88bfddf0aba7d3202c8d5f29131c7b2a2f2bc50e2c9d
7
+ data.tar.gz: 046c0d6890e4ba6fa54dfe132442ae4aebf0672dd9719b41f82b86c0be66aa2042fff964c70018036effaeb12984d87da7e2786011c0e12042a388a8506616f0
@@ -10,4 +10,5 @@ env:
10
10
  - SPROCKETS_VERSION="~> 3.3.0"
11
11
  - SPROCKETS_VERSION="~> 3.4.0"
12
12
  - SPROCKETS_VERSION="~> 3.5.0"
13
+ - SPROCKETS_VERSION="~> 3.6.0"
13
14
  - SPROCKETS_VERSION="~> 4.0.0.beta2"
@@ -1,15 +1,12 @@
1
1
  require 'sprockets'
2
2
  require 'barber'
3
3
 
4
+ require 'ember/handlebars/version'
5
+ require 'ember/handlebars/config'
6
+
4
7
  module Ember
5
8
  module Handlebars
6
- autoload :VERSION, 'ember/handlebars/version'
7
- autoload :Config, 'ember/handlebars/config'
8
- autoload :Helper, 'ember/handlebars/helper'
9
-
10
9
  class Template
11
- include Helper
12
-
13
10
  class << self
14
11
  def configure
15
12
  yield config
@@ -30,6 +27,10 @@ module Ember
30
27
  env.register_transformer 'text/x-ember-handlebars', 'application/javascript', self
31
28
  end
32
29
 
30
+ def setup_ember_template_compiler(path)
31
+ Barber::Ember::Precompiler.ember_template_compiler_path = path
32
+ end
33
+
33
34
  def instance
34
35
  @instance ||= new(config)
35
36
  end
@@ -67,7 +68,7 @@ module Ember
67
68
  template = mustache_to_handlebars(filename, data)
68
69
  end
69
70
 
70
- template_name = actual_name(input)
71
+ template_name = input[:name]
71
72
 
72
73
  module_name =
73
74
  case config.output_type
@@ -110,6 +111,38 @@ module Ember
110
111
 
111
112
  private
112
113
 
114
+ def handlebars?(filename)
115
+ filename.to_s =~ /\.raw\.(handlebars|hjs|hbs)/
116
+ end
117
+
118
+ def mustache_to_handlebars(filename, template)
119
+ if filename =~ /\.mustache\.(handlebars|hjs|hbs)/
120
+ template.gsub(/\{\{(\w[^\}]+)\}\}/){ |x| "{{unbound #{$1}}}" }
121
+ else
122
+ template
123
+ end
124
+ end
125
+
126
+ def amd_template_target(namespace, module_name)
127
+ [namespace, module_name].compact.join('/')
128
+ end
129
+
130
+ def global_template_target(namespace, module_name, config)
131
+ "#{namespace}[#{template_path(module_name, config).inspect}]"
132
+ end
133
+
134
+ def template_path(path, config)
135
+ root = config.templates_root
136
+
137
+ unless root.empty?
138
+ Array(root).each.each do |r|
139
+ path = path.sub(/#{Regexp.quote(r)}\//, '')
140
+ end
141
+ end
142
+
143
+ path.split('/').join(config.templates_path_separator)
144
+ end
145
+
113
146
  def precompile_handlebars(template, input)
114
147
  dependencies = [
115
148
  Barber::Precompiler.compiler_version,
@@ -117,7 +150,7 @@ module Ember
117
150
  ]
118
151
 
119
152
  input[:cache].fetch(_cache_key + dependencies) do
120
- super(template)
153
+ "Handlebars.template(#{Barber::Precompiler.compile(template)});"
121
154
  end
122
155
  end
123
156
 
@@ -130,10 +163,22 @@ module Ember
130
163
  ]
131
164
 
132
165
  input[:cache].fetch(_cache_key + dependencies) do
133
- super(template, ember_template, options)
166
+ "Ember.#{ember_template}.template(#{Barber::Ember::Precompiler.compile(template, options)});"
134
167
  end
135
168
  end
136
169
 
170
+ def compile_handlebars(string)
171
+ "Handlebars.compile(#{indent(string).inspect});"
172
+ end
173
+
174
+ def compile_ember_handlebars(string, ember_template, options = nil)
175
+ "Ember.#{ember_template}.compile(#{indent(string).inspect}, #{options.to_json});"
176
+ end
177
+
178
+ def indent(string)
179
+ string.gsub(/$(.)/m, "\\1 ").strip
180
+ end
181
+
137
182
  def _cache_key
138
183
  [
139
184
  self.class.name,
@@ -141,20 +186,6 @@ module Ember
141
186
  Barber::VERSION
142
187
  ]
143
188
  end
144
-
145
- def actual_name(input)
146
- actual_name = input[:name]
147
-
148
- if input[:filename][File.expand_path(input[:name] + '/index', input[:load_path])]
149
- if actual_name == '.'
150
- actual_name = 'index'
151
- else
152
- actual_name += '/index'
153
- end
154
- end
155
-
156
- actual_name
157
- end
158
189
  end
159
190
  end
160
191
  end
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Handlebars
3
- VERSION = '0.7.3'
3
+ VERSION = '0.7.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember-handlebars-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryunosuke SATO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -117,7 +117,6 @@ files:
117
117
  - bin/setup
118
118
  - ember-handlebars-template.gemspec
119
119
  - lib/ember/handlebars/config.rb
120
- - lib/ember/handlebars/helper.rb
121
120
  - lib/ember/handlebars/template.rb
122
121
  - lib/ember/handlebars/version.rb
123
122
  homepage: https://github.com/tricknotes/ember-handlebars-template
@@ -1,69 +0,0 @@
1
- module Ember
2
- module Handlebars
3
- module Helper
4
- def self.included(base)
5
- base.extend ClassMethods
6
- end
7
-
8
- module ClassMethods
9
- def setup_ember_template_compiler(path)
10
- Barber::Ember::Precompiler.ember_template_compiler_path = path
11
- end
12
- end
13
-
14
- private
15
-
16
- def handlebars?(filename)
17
- filename.to_s =~ /\.raw\.(handlebars|hjs|hbs)/
18
- end
19
-
20
- def mustache_to_handlebars(filename, template)
21
- if filename =~ /\.mustache\.(handlebars|hjs|hbs)/
22
- template.gsub(/\{\{(\w[^\}]+)\}\}/){ |x| "{{unbound #{$1}}}" }
23
- else
24
- template
25
- end
26
- end
27
-
28
- def amd_template_target(namespace, module_name)
29
- [namespace, module_name].compact.join('/')
30
- end
31
-
32
- def global_template_target(namespace, module_name, config)
33
- "#{namespace}[#{template_path(module_name, config).inspect}]"
34
- end
35
-
36
- def template_path(path, config)
37
- root = config.templates_root
38
-
39
- unless root.empty?
40
- Array(root).each.each do |r|
41
- path = path.sub(/#{Regexp.quote(r)}\//, '')
42
- end
43
- end
44
-
45
- path.split('/').join(config.templates_path_separator)
46
- end
47
-
48
- def compile_handlebars(string)
49
- "Handlebars.compile(#{indent(string).inspect});"
50
- end
51
-
52
- def precompile_handlebars(string)
53
- "Handlebars.template(#{Barber::Precompiler.compile(string)});"
54
- end
55
-
56
- def compile_ember_handlebars(string, ember_template = 'Handlebars', options = nil)
57
- "Ember.#{ember_template}.compile(#{indent(string).inspect}, #{options.to_json});"
58
- end
59
-
60
- def precompile_ember_handlebars(string, ember_template = 'Handlebars', options = nil)
61
- "Ember.#{ember_template}.template(#{Barber::Ember::Precompiler.compile(string, options)});"
62
- end
63
-
64
- def indent(string)
65
- string.gsub(/$(.)/m, "\\1 ").strip
66
- end
67
- end
68
- end
69
- end