sht_rails 0.2.0 → 0.2.1

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: a6e28441b4e0c90c74a3520216d36f8966c180bb
4
- data.tar.gz: 9035f8bee67957c318c5f35c97366c5b0db70dc2
3
+ metadata.gz: 55986001ebb59627ef7ace326b839c1cce329e5b
4
+ data.tar.gz: a01c33c272d56e7d44ddb6516b98ff551bfed07d
5
5
  SHA512:
6
- metadata.gz: 4330f6dd875b91b41ae8360b32a6390fe3045c2729e1e10c92cf13c202791d2229b89736277d8e582ccdba4cca2d6bdc2129295faa00b9bb40d224b6262ce311
7
- data.tar.gz: 71078dfe27afc03f922d887a2be1b97c07ccf546fb0d39c9640956f41a31afa0b970a07e463958124c6abbb0fa5a1470036f78a9fc6d2cc6177a2521b5568c6f
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)
@@ -10,7 +10,9 @@ module ShtRails
10
10
  # end
11
11
 
12
12
  module Config
13
- attr_accessor :template_base_path, :template_extension, :action_view_key, :template_namespace, :helper_path
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
@@ -3,9 +3,7 @@ require 'execjs'
3
3
 
4
4
  module ShtRails
5
5
  class Tilt < Tilt::Template
6
- def self.default_mime_type
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!(/^_/, '')
@@ -1,3 +1,3 @@
1
1
  module ShtRails
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end