sht_rails 0.2.0 → 0.2.1
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/README.md +9 -0
- data/lib/sht_rails/config.rb +3 -1
- data/lib/sht_rails/tilt.rb +3 -5
- data/lib/sht_rails/version.rb +1 -1
- data/vendor/assets/javascripts/handlebars.js +1550 -1005
- data/vendor/assets/javascripts/handlebars.runtime.js +422 -213
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55986001ebb59627ef7ace326b839c1cce329e5b
|
4
|
+
data.tar.gz: a01c33c272d56e7d44ddb6516b98ff551bfed07d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1451ce66f311d3da13e3925451020e16d9c44823af0a32b6b4ada4bb9414778b0b06d55ac9d9a63954072526dfd71e3faecfcfe02e52793ea60594c6895c201
|
7
|
+
data.tar.gz: a55ff6774ffacb45bba3714396540c6de7d148119c98efd02764c271bbeda74247551102ff8ec4dde13ba43ccc9f87426b92f981a8c89f516071bf401aee9845
|
data/README.md
CHANGED
@@ -45,6 +45,15 @@ The same template you can render in JavaScript:
|
|
45
45
|
config.template_base_path = Rails.root.join("app", "templates") # templates dir
|
46
46
|
end
|
47
47
|
|
48
|
+
### Note on precompiling assets and custom configs
|
49
|
+
|
50
|
+
In Rails, if you have config.assets.initialize\_on\_precompile set to false, but have placed the above config in an initializer, it will not run. To get around this, you can do the following in application.rb:
|
51
|
+
|
52
|
+
if "assets" == ENV["RAILS_GROUPS"] || ["development", "test"].include?(ENV["RAILS_ENV"])
|
53
|
+
ShtRails.template_namespace = 'JST'
|
54
|
+
end
|
55
|
+
|
56
|
+
|
48
57
|
## Demo
|
49
58
|
|
50
59
|
Site: [http://st-rails-example.herokuapp.com](http://st-rails-example.herokuapp.com)
|
data/lib/sht_rails/config.rb
CHANGED
@@ -10,7 +10,9 @@ module ShtRails
|
|
10
10
|
# end
|
11
11
|
|
12
12
|
module Config
|
13
|
-
|
13
|
+
extend self
|
14
|
+
|
15
|
+
attr_writer :template_base_path, :template_extension, :action_view_key, :template_namespace, :helper_path
|
14
16
|
|
15
17
|
def configure
|
16
18
|
yield self
|
data/lib/sht_rails/tilt.rb
CHANGED
@@ -3,9 +3,7 @@ require 'execjs'
|
|
3
3
|
|
4
4
|
module ShtRails
|
5
5
|
class Tilt < Tilt::Template
|
6
|
-
|
7
|
-
'application/javascript'
|
8
|
-
end
|
6
|
+
self.default_mime_type = 'application/javascript'
|
9
7
|
|
10
8
|
def prepare
|
11
9
|
@namespace = "this.#{ShtRails.template_namespace}"
|
@@ -24,13 +22,13 @@ module ShtRails
|
|
24
22
|
def evaluate(scope, locals, &block)
|
25
23
|
template_key = path_to_key scope
|
26
24
|
<<-HandlebarsTemplate
|
27
|
-
(function() {
|
25
|
+
(function() {
|
28
26
|
#{namespace} || (#{namespace} = {});
|
29
27
|
#{namespace}[#{template_key.inspect}] = Handlebars.template(#{precompile(data)});
|
30
28
|
}).call(this);
|
31
29
|
HandlebarsTemplate
|
32
30
|
end
|
33
|
-
|
31
|
+
|
34
32
|
def path_to_key(scope)
|
35
33
|
path = scope.logical_path.to_s.split('/')
|
36
34
|
path.last.gsub!(/^_/, '')
|
data/lib/sht_rails/version.rb
CHANGED