ember-rails-lite 0.12.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +220 -47
- data/lib/{ember-rails.rb → ember-rails-lite.rb} +0 -0
- data/lib/ember/rails/engine.rb +9 -4
- data/lib/ember/rails/version.rb +1 -1
- data/lib/ember_rails.rb +39 -28
- data/lib/generators/ember/adapter_generator.rb +21 -0
- data/lib/generators/ember/bootstrap_generator.rb +27 -9
- data/lib/generators/ember/component_generator.rb +28 -0
- data/lib/generators/ember/controller_generator.rb +1 -0
- data/lib/generators/ember/generator_helpers.rb +32 -5
- data/lib/generators/ember/install_generator.rb +169 -13
- data/lib/generators/ember/model_generator.rb +1 -0
- data/lib/generators/ember/resource_generator.rb +1 -0
- data/lib/generators/ember/resource_override.rb +8 -2
- data/lib/generators/ember/route_generator.rb +1 -0
- data/lib/generators/ember/template_generator.rb +4 -1
- data/lib/generators/ember/view_generator.rb +1 -0
- data/lib/generators/templates/adapter.js +5 -0
- data/lib/generators/templates/adapter.js.coffee +5 -0
- data/lib/generators/templates/adapter.js.em +3 -0
- data/lib/generators/templates/app.js +4 -2
- data/lib/generators/templates/app.js.coffee +3 -1
- data/lib/generators/templates/app.js.em +11 -0
- data/lib/generators/templates/{application.handlebars → application.hbs} +0 -0
- data/lib/generators/templates/application.js +4 -2
- data/lib/generators/templates/application.js.coffee +3 -1
- data/lib/generators/templates/application.js.em +10 -0
- data/lib/generators/templates/application_adapter.js +5 -0
- data/lib/generators/templates/application_adapter.js.coffee +5 -0
- data/lib/generators/templates/application_adapter.js.em +3 -0
- data/lib/generators/templates/array_controller.js +1 -1
- data/lib/generators/templates/array_controller.js.em +3 -0
- data/lib/generators/templates/component.js +4 -0
- data/lib/generators/templates/component.js.coffee +6 -0
- data/lib/generators/templates/component.js.em +6 -0
- data/lib/generators/templates/component.template.hbs +2 -0
- data/lib/generators/templates/controller.js.em +3 -0
- data/lib/generators/templates/model.js +1 -1
- data/lib/generators/templates/model.js.coffee +1 -1
- data/lib/generators/templates/model.js.em +12 -0
- data/lib/generators/templates/object_controller.js.em +3 -0
- data/lib/generators/templates/route.js.em +3 -0
- data/lib/generators/templates/router.js.em +5 -0
- data/lib/generators/templates/{template.handlebars → template.hbs} +0 -0
- data/lib/generators/templates/view.js.em +4 -0
- metadata +112 -92
- data/lib/ember/handlebars/template.rb +0 -102
- data/lib/ember/handlebars/version.rb +0 -5
- data/lib/generators/templates/store.js +0 -6
- data/lib/generators/templates/store.js.coffee +0 -6
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'sprockets'
|
2
|
-
require 'sprockets/engines'
|
3
|
-
require 'barber'
|
4
|
-
|
5
|
-
module Ember
|
6
|
-
module Handlebars
|
7
|
-
class Template < Tilt::Template
|
8
|
-
def self.default_mime_type
|
9
|
-
'application/javascript'
|
10
|
-
end
|
11
|
-
|
12
|
-
def prepare; end
|
13
|
-
|
14
|
-
def evaluate(scope, locals, &block)
|
15
|
-
target = template_target(scope)
|
16
|
-
raw = handlebars?(scope)
|
17
|
-
|
18
|
-
if raw
|
19
|
-
template = data
|
20
|
-
else
|
21
|
-
template = mustache_to_handlebars(scope, data)
|
22
|
-
end
|
23
|
-
|
24
|
-
if configuration.precompile
|
25
|
-
if raw
|
26
|
-
template = precompile_handlebars(template)
|
27
|
-
else
|
28
|
-
template = precompile_ember_handlebars(template)
|
29
|
-
end
|
30
|
-
else
|
31
|
-
if raw
|
32
|
-
template = compile_handlebars(data)
|
33
|
-
else
|
34
|
-
template = compile_ember_handlebars(template)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
"#{target} = #{template}\n"
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def handlebars?(scope)
|
44
|
-
scope.pathname.to_s =~ /\.raw\.(handlebars|hjs|hbs)/
|
45
|
-
end
|
46
|
-
|
47
|
-
def template_target(scope)
|
48
|
-
"Ember.TEMPLATES[#{template_path(scope.logical_path).inspect}]"
|
49
|
-
end
|
50
|
-
|
51
|
-
def compile_handlebars(string)
|
52
|
-
"Handlebars.compile(#{indent(string).inspect});"
|
53
|
-
end
|
54
|
-
|
55
|
-
def precompile_handlebars(string)
|
56
|
-
Barber::FilePrecompiler.call(string)
|
57
|
-
end
|
58
|
-
|
59
|
-
def compile_ember_handlebars(string)
|
60
|
-
"Ember.Handlebars.compile(#{indent(string).inspect});"
|
61
|
-
end
|
62
|
-
|
63
|
-
def precompile_ember_handlebars(string)
|
64
|
-
Barber::Ember::FilePrecompiler.call(string)
|
65
|
-
end
|
66
|
-
|
67
|
-
def mustache_to_handlebars(scope, template)
|
68
|
-
if scope.pathname.to_s =~ /\.mustache\.(handlebars|hjs|hbs)/
|
69
|
-
template.gsub(/\{\{(\w[^\}\}]+)\}\}/){ |x| "{{unbound #{$1}}}" }
|
70
|
-
else
|
71
|
-
template
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def template_path(path)
|
76
|
-
root = configuration.templates_root
|
77
|
-
|
78
|
-
if root.kind_of? Array
|
79
|
-
root.each do |root|
|
80
|
-
path.sub!(/#{Regexp.quote(root)}\//, '')
|
81
|
-
end
|
82
|
-
else
|
83
|
-
unless root.empty?
|
84
|
-
path.sub!(/#{Regexp.quote(root)}\/?/, '')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
path = path.split('/')
|
89
|
-
|
90
|
-
path.join(configuration.templates_path_separator)
|
91
|
-
end
|
92
|
-
|
93
|
-
def configuration
|
94
|
-
::Rails.configuration.handlebars
|
95
|
-
end
|
96
|
-
|
97
|
-
def indent(string)
|
98
|
-
string.gsub(/$(.)/m, "\\1 ").strip
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|