ember-handlebars-template 0.3.6 → 0.4.0

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: 6a29668098d116177dc267ed5057ce097c4095c1
4
- data.tar.gz: 6977d2e667ce0d2d8a890dda7d6b52d70d7b1d77
3
+ metadata.gz: 77991c6edf3ca17f210172688eb5b36b703ec561
4
+ data.tar.gz: 32dbb7ef4acfc388b94858469440f58882c8da47
5
5
  SHA512:
6
- metadata.gz: f7f5c608393f93a019b6d716ad11ad9673b023d3b7d89a7682ed986f1ed71a6cb6890de9ce2d37f92d16ad6ec8139e3babb0ba02474e002bd4ab9a12892a146e
7
- data.tar.gz: fa78c9a12e09c25c188d2deb522743505cf011f42d5ba51af9f8de5ffc31f28fc2ef7230c3a52466a23db37b607c9a37ee8988a7e36d85975cb502053e4d569a
6
+ metadata.gz: 16a748a77f12c1762e284e1bb434c9783da663703d07db7c4707bb37c2b49d438885953bb4cbb91f22f14b95eeff41763b2f49bcb487831c82cc81031631b743
7
+ data.tar.gz: 58559bd9046de7ae82a9ae9feda611b87383b49e699cfb545f8d46ab4fbe918eb51bf3d5d8131158de776c7c27ef31f119d58beb08e46a887add2e4b7ec2e40c
data/.travis.yml CHANGED
@@ -2,15 +2,9 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
+ - 2.0.0
5
6
  - 2.1
6
7
  - 2.2
7
- - 2.3.0
8
8
  env:
9
9
  matrix:
10
- - SPROCKETS_VERSION="~> 2.1.0"
11
- - SPROCKETS_VERSION="~> 2.12.0"
12
- - SPROCKETS_VERSION="~> 3.0.0"
13
- - SPROCKETS_VERSION="~> 3.1.0"
14
- - SPROCKETS_VERSION="~> 3.2.0"
15
10
  - SPROCKETS_VERSION="~> 3.3.0"
16
- - SPROCKETS_VERSION="~> 3.4.0"
@@ -18,9 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'sprockets', '>= 2.1', '< 3.5'
22
- spec.add_dependency 'barber', '>= 0.10.0'
23
- spec.add_dependency 'tilt'
21
+ spec.add_dependency 'sprockets', '>= 3.3', '< 3.4'
22
+ spec.add_dependency 'barber', '>= 0.9.0'
24
23
 
25
24
  spec.add_development_dependency 'bundler', '~> 1.7'
26
25
  spec.add_development_dependency 'rake', '~> 10.0'
@@ -7,13 +7,124 @@ module Ember
7
7
  autoload :Config, 'ember/handlebars/config'
8
8
  autoload :Helper, 'ember/handlebars/helper'
9
9
 
10
- case Sprockets::VERSION
11
- when /\A2\./, /\A3\.[12]/
12
- autoload :Template, 'ember/handlebars/templates/sprockets+tilt'
13
- when /\A3\.[034]/
14
- autoload :Template, 'ember/handlebars/templates/sprockets_only'
15
- else
16
- raise "Unsupported sprockets version: #{Sprockets::VERSION}"
10
+ class Template
11
+ include Helper
12
+
13
+ class << self
14
+ def configure
15
+ yield config
16
+ end
17
+
18
+ def config
19
+ @config ||= Config.new
20
+ end
21
+
22
+ def setup(env)
23
+ env.register_engine '.hbs', self, mime_type: 'application/javascript'
24
+ env.register_engine '.handlebars', self, mime_type: 'application/javascript'
25
+ end
26
+
27
+ def instance
28
+ @instance ||= new(config)
29
+ end
30
+
31
+ def call(input)
32
+ instance.call(input)
33
+ end
34
+ end
35
+
36
+ attr_reader :config
37
+
38
+ def initialize(config = self.class.config.dup)
39
+ @config = config
40
+ end
41
+
42
+ def call(input)
43
+ data = input[:data]
44
+ filename = input[:filename]
45
+
46
+ raw = handlebars?(filename)
47
+
48
+ if raw
49
+ template = data
50
+ else
51
+ template = mustache_to_handlebars(filename, data)
52
+ end
53
+
54
+ if config.precompile
55
+ if raw
56
+ template = precompile_handlebars(template)
57
+ else
58
+ template = precompile_ember_handlebars(template, config.ember_template, input)
59
+ end
60
+ else
61
+ if raw
62
+ template = compile_handlebars(data)
63
+ else
64
+ template = compile_ember_handlebars(template, config.ember_template)
65
+ end
66
+ end
67
+
68
+ case config.output_type
69
+ when :amd
70
+ target = amd_template_target(config.amd_namespace, actual_name(input))
71
+
72
+ "define('#{target}', ['exports'], function(__exports__){ __exports__['default'] = #{template} });"
73
+ when :global
74
+ target = global_template_target(actual_name(input), config)
75
+
76
+ "#{target} = #{template}\n"
77
+ else
78
+ raise "Unsupported `output_type`: #{config.output_type}"
79
+ end
80
+ end
81
+
82
+ private
83
+
84
+ def precompile_handlebars(template, input)
85
+ dependencies = [
86
+ Barber::Precompiler.compiler_version,
87
+ template,
88
+ ]
89
+
90
+ input[:cache].fetch(_cache_key + dependencies) do
91
+ super(template)
92
+ end
93
+ end
94
+
95
+ def precompile_ember_handlebars(template, ember_template, input)
96
+ dependencies = [
97
+ Barber::Ember::Precompiler.compiler_version,
98
+ ember_template,
99
+ template
100
+ ]
101
+
102
+ input[:cache].fetch(_cache_key + dependencies) do
103
+ super(template, ember_template)
104
+ end
105
+ end
106
+
107
+ def _cache_key
108
+ [
109
+ self.class.name,
110
+ VERSION,
111
+ Barber::VERSION
112
+ ]
113
+ end
114
+
115
+ def actual_name(input)
116
+ actual_name = input[:name]
117
+
118
+ if input[:filename][File.expand_path(input[:name] + '/index', input[:load_path])]
119
+ if actual_name == '.'
120
+ actual_name = 'index'
121
+ else
122
+ actual_name += '/index'
123
+ end
124
+ end
125
+
126
+ actual_name
127
+ end
17
128
  end
18
129
  end
19
130
  end
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Handlebars
3
- VERSION = '0.3.6'
3
+ VERSION = '0.4.0'
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.3.6
4
+ version: 0.4.0
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: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -16,48 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: '3.3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '3.5'
22
+ version: '3.4'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '2.1'
29
+ version: '3.3'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '3.5'
32
+ version: '3.4'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: barber
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.10.0
39
+ version: 0.9.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 0.10.0
47
- - !ruby/object:Gem::Dependency
48
- name: tilt
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
46
+ version: 0.9.0
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: bundler
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -119,8 +105,6 @@ files:
119
105
  - lib/ember/handlebars/config.rb
120
106
  - lib/ember/handlebars/helper.rb
121
107
  - lib/ember/handlebars/template.rb
122
- - lib/ember/handlebars/templates/sprockets+tilt.rb
123
- - lib/ember/handlebars/templates/sprockets_only.rb
124
108
  - lib/ember/handlebars/version.rb
125
109
  homepage: https://github.com/tricknotes/ember-handlebars-template
126
110
  licenses:
@@ -142,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
126
  version: '0'
143
127
  requirements: []
144
128
  rubyforge_project:
145
- rubygems_version: 2.5.1
129
+ rubygems_version: 2.4.7
146
130
  signing_key:
147
131
  specification_version: 4
148
132
  summary: The sprockets template for Ember Handlebars.
@@ -1,82 +0,0 @@
1
- require 'tilt'
2
-
3
- module Ember
4
- module Handlebars
5
- class Template < Tilt::Template
6
- include Helper
7
-
8
- class << self
9
- def configure
10
- yield config
11
- end
12
-
13
- def default_mime_type
14
- 'application/javascript'
15
- end
16
-
17
- def setup(env)
18
- env.register_engine '.mustache.hbs', self
19
- env.register_engine '.mustache.hjs', self
20
- env.register_engine '.mustache.handlebars', self
21
-
22
- env.register_engine '.hbs', self
23
- env.register_engine '.hjs', self
24
- env.register_engine '.handlebars', self
25
- end
26
-
27
- def config
28
- @config ||= Config.new
29
- end
30
-
31
- def handlebars_available?
32
- Barber::Precompiler.handlebars_available?
33
- end
34
- end
35
-
36
- def prepare; end
37
-
38
- def evaluate(scope, locals, &block)
39
- filename = scope.pathname.to_s
40
-
41
- raw = handlebars?(filename)
42
-
43
- if raw
44
- template = data
45
- else
46
- template = mustache_to_handlebars(filename, data)
47
- end
48
-
49
- if config.precompile
50
- if raw
51
- template = precompile_handlebars(template)
52
- else
53
- template = precompile_ember_handlebars(template, config.ember_template)
54
- end
55
- else
56
- if raw
57
- template = compile_handlebars(data)
58
- else
59
- template = compile_ember_handlebars(template, config.ember_template)
60
- end
61
- end
62
-
63
- case config.output_type
64
- when :amd
65
- target = amd_template_target(config.amd_namespace, scope.logical_path.split(".").first)
66
-
67
- "define('#{target}', ['exports'], function(__exports__){ __exports__['default'] = #{template} });"
68
- when :global
69
- target = global_template_target(scope.logical_path, config)
70
-
71
- "#{target} = #{template}\n"
72
- else
73
- raise "Unsupported `output_type`: #{config.output_type}"
74
- end
75
- end
76
-
77
- def config
78
- @config ||= self.class.config.dup
79
- end
80
- end
81
- end
82
- end
@@ -1,128 +0,0 @@
1
- module Ember
2
- module Handlebars
3
- class Template
4
- include Helper
5
-
6
- class << self
7
- def configure
8
- yield config
9
- end
10
-
11
- def config
12
- @config ||= Config.new
13
- end
14
-
15
- def setup(env)
16
- env.register_engine '.hbs', self, mime_type: 'application/javascript'
17
- env.register_engine '.hjs', self, mime_type: 'application/javascript'
18
- env.register_engine '.handlebars', self, mime_type: 'application/javascript'
19
- end
20
-
21
- def instance
22
- @instance ||= new(config)
23
- end
24
-
25
- def call(input)
26
- instance.call(input)
27
- end
28
-
29
- def handlebars_available?
30
- Barber::Precompiler.handlebars_available?
31
- end
32
- end
33
-
34
- attr_reader :config
35
-
36
- def initialize(config = self.class.config.dup)
37
- @config = config
38
- end
39
-
40
- def call(input)
41
- data = input[:data]
42
- filename = input[:filename]
43
-
44
- raw = handlebars?(filename)
45
-
46
- if raw
47
- template = data
48
- else
49
- template = mustache_to_handlebars(filename, data)
50
- end
51
-
52
- if config.precompile
53
- if raw
54
- template = precompile_handlebars(template)
55
- else
56
- template = precompile_ember_handlebars(template, config.ember_template, input)
57
- end
58
- else
59
- if raw
60
- template = compile_handlebars(data)
61
- else
62
- template = compile_ember_handlebars(template, config.ember_template)
63
- end
64
- end
65
-
66
- case config.output_type
67
- when :amd
68
- target = amd_template_target(config.amd_namespace, actual_name(input))
69
-
70
- "define('#{target}', ['exports'], function(__exports__){ __exports__['default'] = #{template} });"
71
- when :global
72
- target = global_template_target(actual_name(input), config)
73
-
74
- "#{target} = #{template}\n"
75
- else
76
- raise "Unsupported `output_type`: #{config.output_type}"
77
- end
78
- end
79
-
80
- private
81
-
82
- def precompile_handlebars(template, input)
83
- dependencies = [
84
- Barber::Precompiler.compiler_version,
85
- template,
86
- ]
87
-
88
- input[:cache].fetch(_cache_key + dependencies) do
89
- super(template)
90
- end
91
- end
92
-
93
- def precompile_ember_handlebars(template, ember_template, input)
94
- dependencies = [
95
- Barber::Ember::Precompiler.compiler_version,
96
- ember_template,
97
- template
98
- ]
99
-
100
- input[:cache].fetch(_cache_key + dependencies) do
101
- super(template, ember_template)
102
- end
103
- end
104
-
105
- def _cache_key
106
- [
107
- self.class.name,
108
- VERSION,
109
- Barber::VERSION
110
- ]
111
- end
112
-
113
- def actual_name(input)
114
- actual_name = input[:name]
115
-
116
- if input[:filename][File.expand_path(input[:name] + '/index', input[:load_path])]
117
- if actual_name == '.'
118
- actual_name = 'index'
119
- else
120
- actual_name += '/index'
121
- end
122
- end
123
-
124
- actual_name
125
- end
126
- end
127
- end
128
- end