sht_rails 0.2.2 → 0.2.3

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: 6f8eda11972fbcbe42b2c2ccdde61bbbb41bcbcb
4
- data.tar.gz: 26691332a87a993617f3c6df24624f35a05ececa
3
+ metadata.gz: 06152679303d5b7b56946fcadba6900ba9882cd3
4
+ data.tar.gz: 1781a842e9dcf08f62e4a281b555bacca0aa3e34
5
5
  SHA512:
6
- metadata.gz: f481e298334fa2826a7ff0475f1a55d47871aee8e1acac69d34b2bd959caa6f54aeaa04a89ace2a1cb174dc1425ccec8259dc0c39731ad80db2a30856471d1ad
7
- data.tar.gz: af93f3405273c7e603317251b250091eff0b6cb2c0599b6ef61859965a493cc690c3db269e37ac3fc8b175617d0f452ba89163373353d5d792e35d308db18933
6
+ metadata.gz: 4c6f21d1d3b3094943765a641075571ebe4ba9c1a169d06e907a01b6554ad7780f89217822bba60149d39a4325005f3c58854227e82e19e38b0eccacf6492e03
7
+ data.tar.gz: 7a363dae7895bb5d33ea816bed15009c1a49f72b4f3f502d9bf2336e0caa4c423bd455359c1219242f6605866652f18fcfa5fae63a1efb998f285e2bc13abd6a
@@ -0,0 +1,13 @@
1
+ module ShtRails
2
+ class AssetDependency
3
+ def initialize(path)
4
+ @path = path
5
+ end
6
+
7
+ def source
8
+ asset = Rails.application.assets.find_asset(@path)
9
+
10
+ asset.source unless asset.nil?
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,6 @@
1
+ require 'sht_rails/asset_dependency'
2
+ require 'sht_rails/content_dependency'
3
+
1
4
  module ShtRails
2
5
  # Change config options in an initializer:
3
6
  #
@@ -12,7 +15,7 @@ module ShtRails
12
15
  module Config
13
16
  extend self
14
17
 
15
- attr_writer :template_base_path, :template_extension, :action_view_key, :template_namespace, :helper_path
18
+ attr_writer :template_base_path, :template_extension, :action_view_key, :template_namespace, :helper_path, :dependencies
16
19
 
17
20
  def configure
18
21
  yield self
@@ -37,5 +40,9 @@ module ShtRails
37
40
  def helper_path
38
41
  @helper_path ||= 'templates/helpers.js'
39
42
  end
43
+
44
+ def dependencies
45
+ @dependencies ||= []
46
+ end
40
47
  end
41
48
  end
@@ -0,0 +1,11 @@
1
+ module ShtRails
2
+ class ContentDependency
3
+ def initialize(content)
4
+ @content = content
5
+ end
6
+
7
+ def source
8
+ @content
9
+ end
10
+ end
11
+ end
@@ -5,11 +5,14 @@ module ShtRails
5
5
 
6
6
  module Handlebars
7
7
  def self.context(partials = nil)
8
- @context = nil unless ActionView::Resolver.caching?
9
- @context ||= begin
8
+ @context = begin
10
9
  context = ::Handlebars::Context.new
10
+ runtime = context.instance_variable_get(:@js)
11
+
12
+ ShtRails.dependencies.each { |dependency| runtime.eval dependency.source }
13
+
11
14
  if helpers = Rails.application.assets.find_asset(ShtRails.helper_path)
12
- context.instance_variable_get(:@js).eval helpers.source
15
+ runtime.eval helpers.source
13
16
  end
14
17
  partials.each { |key, value| context.register_partial(key, value) } if partials
15
18
  context
@@ -1,3 +1,3 @@
1
1
  module ShtRails
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sht_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vasiliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-09 00:00:00.000000000 Z
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -112,7 +112,9 @@ files:
112
112
  - lib/generators/sht_rails/helpers.rb
113
113
  - lib/generators/sht_rails/install/install_generator.rb
114
114
  - lib/sht_rails.rb
115
+ - lib/sht_rails/asset_dependency.rb
115
116
  - lib/sht_rails/config.rb
117
+ - lib/sht_rails/content_dependency.rb
116
118
  - lib/sht_rails/engine.rb
117
119
  - lib/sht_rails/handlebars.rb
118
120
  - lib/sht_rails/tilt.rb