ember-handlebars-template 0.6.0 → 0.7.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: 6b4d0d73a1c7de72d9dd6374b991694fbf66666b
4
- data.tar.gz: 1715422100d413db2b51ea25892c72b43d22410d
3
+ metadata.gz: 18e4e96c2704e2d98f3266ca09d8adfbe5221e4a
4
+ data.tar.gz: a7a36a43f26f7ce2003424203cc95631b346d3f4
5
5
  SHA512:
6
- metadata.gz: 41559a84246011cc12c4758a8c3f44cda51175d460a484897f831f22c31bcb63283fb9ba747b1576c8e80beb6339d99e351517baa0fef27d4cae295a65635d0b
7
- data.tar.gz: d0a8f4badb7cc6eb70d652aba0d05b6ca9ac4e9c3f0c3f63f932196f271537fef06438710a19159630d91b149bf28ce80a4297b558b936e7d979dc184c4d6fa7
6
+ metadata.gz: 21afa1657785640b5650e05751c26b53aec073775034ca8d157f570193b3838f6cd78b52bcefb7881523e99635f357adecb6e0ade925b997b53254fe22dd6bd7
7
+ data.tar.gz: ad621626fe61bfbe3c43414c148abacc004396c1d5db8d6eb5ddb8c25b51c155f7b812359d24a9b00661f8daf3948bc028c09f182d4a0a91b6e58bca636f3986
data/.travis.yml CHANGED
@@ -4,7 +4,8 @@ cache: bundler
4
4
  rvm:
5
5
  - 2.0.0
6
6
  - 2.1
7
- - 2.2
7
+ - 2.2.4
8
+ - 2.3.0
8
9
  env:
9
10
  matrix:
10
11
  - SPROCKETS_VERSION="~> 3.3.0"
data/README.md CHANGED
@@ -28,49 +28,57 @@ $ gem install ember-handlebars-template
28
28
  Sprockets.register_engine '.hbs', Ember::Handlebars::Template # or other extension which you like.
29
29
  ```
30
30
 
31
+ It can also compile "raw" templates – pure Handlebars templates, independent of Ember. They need to have a suffix `.raw.hbs` (the last extension depends on what was registered with `register_engine`).
32
+
31
33
  ## Options
32
34
 
33
- You can overwrite config as the followings:
35
+ You can overwrite config like this:
34
36
 
35
37
  ``` ruby
36
38
  Ember::Handlebars::Template.configure do |config|
37
39
  config.precompile = true
38
40
 
39
- # You can overwrite other config
41
+ # Or any of the options below.
40
42
  end
41
43
  ```
42
44
 
43
- ### precompile
45
+ ### `precompile`
44
46
 
45
47
  Type: `Boolean`
46
48
 
47
49
  Enables or disables precompilation.(default: `true`)
48
50
 
49
- ### ember_template
51
+ ### `ember_template`
50
52
 
51
53
  Type: `String`
52
54
 
53
55
  Default which Ember template type to compile. `HTMLBars` / `Handlebars`. (default: `HTMLBars`)
54
56
 
55
- ### output_type
57
+ ### `output_type`
56
58
 
57
59
  Type: `Symbol`
58
60
 
59
61
  Configures the style of output. `:global` / `:amd`. (default `:global`)
60
62
 
61
- ### amd_namespace
63
+ ### `amd_namespace`
62
64
 
63
65
  Type: `String`
64
66
 
65
67
  Configures the module prefix for AMD formatted output. (default: `nil`)
66
68
 
67
- ### templates_root
69
+ ### `raw_template_namespace`
70
+
71
+ Type: `String`
72
+
73
+ Configures the namespace that the raw templates are assigned to. (default: `JST`)
74
+
75
+ ### `templates_root`
68
76
 
69
77
  Type: `String`
70
78
 
71
79
  Sets the root path for templates to be looked up in. (default: `templates`)
72
80
 
73
- ### templates_path_separator
81
+ ### `templates_path_separator`
74
82
 
75
83
  Type: `String`
76
84
 
@@ -23,5 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.7'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'handlebars-source'
26
27
  spec.add_development_dependency 'minitest'
27
28
  end
@@ -5,6 +5,7 @@ module Ember
5
5
  :ember_template,
6
6
  :output_type,
7
7
  :amd_namespace,
8
+ :raw_template_namespace,
8
9
  :templates_root,
9
10
  :templates_path_separator
10
11
 
@@ -13,6 +14,7 @@ module Ember
13
14
  self.ember_template = 'HTMLBars'
14
15
  self.output_type = :global
15
16
  self.amd_namespace = nil
17
+ self.raw_template_namespace = 'JST'
16
18
  self.templates_root = 'templates'
17
19
  self.templates_path_separator = '/'
18
20
  end
@@ -29,8 +29,8 @@ module Ember
29
29
  [namespace, module_name].compact.join('/')
30
30
  end
31
31
 
32
- def global_template_target(module_name, config)
33
- "Ember.TEMPLATES[#{template_path(module_name, config).inspect}]"
32
+ def global_template_target(namespace, module_name, config)
33
+ "#{namespace}[#{template_path(module_name, config).inspect}]"
34
34
  end
35
35
 
36
36
  def template_path(path, config)
@@ -42,9 +42,7 @@ module Ember
42
42
  end
43
43
  end
44
44
 
45
- path = path.split('/')
46
-
47
- path.join(config.templates_path_separator)
45
+ path.split('/').join(config.templates_path_separator)
48
46
  end
49
47
 
50
48
  def compile_handlebars(string)
@@ -20,9 +20,12 @@ module Ember
20
20
  end
21
21
 
22
22
  def setup(env)
23
- env.register_engine '.hbs', self, mime_type: 'application/javascript'
24
- env.register_engine '.hjs', self, mime_type: 'application/javascript'
25
- env.register_engine '.handlebars', self, mime_type: 'application/javascript'
23
+ %w(.raw.hbs .raw.hjs .raw.handlebars
24
+ .hbs .hjs .handlebars).each do |extension|
25
+ env.register_engine extension,
26
+ self,
27
+ mime_type: 'application/javascript'
28
+ end
26
29
  end
27
30
 
28
31
  def instance
@@ -72,7 +75,7 @@ module Ember
72
75
 
73
76
  if config.precompile
74
77
  if raw
75
- template = precompile_handlebars(template)
78
+ template = precompile_handlebars(template, input)
76
79
  else
77
80
  template = precompile_ember_handlebars(template, config.ember_template, input, meta)
78
81
  end
@@ -88,7 +91,8 @@ module Ember
88
91
  when :amd
89
92
  "define('#{module_name}', ['exports'], function(__exports__){ __exports__['default'] = #{template} });"
90
93
  when :global
91
- target = global_template_target(template_name, config)
94
+ namespace = raw ? config.raw_template_namespace : 'Ember.TEMPLATES'
95
+ target = global_template_target(namespace, template_name, config)
92
96
 
93
97
  "#{target} = #{template}\n"
94
98
  else
@@ -1,5 +1,5 @@
1
1
  module Ember
2
2
  module Handlebars
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.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.6.0
4
+ version: 0.7.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: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: handlebars-source
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: minitest
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
140
  version: '0'
127
141
  requirements: []
128
142
  rubyforge_project:
129
- rubygems_version: 2.5.0
143
+ rubygems_version: 2.5.1
130
144
  signing_key:
131
145
  specification_version: 4
132
146
  summary: The sprockets template for Ember Handlebars.