slim-rails 2.0.4 → 2.1.0

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.
data/README.md CHANGED
@@ -1,12 +1,23 @@
1
1
  # slim-rails
2
2
 
3
- slim-rails provides Slim generators for Rails 3 and 4. It was based on [haml-rails](http://github.com/indirect/haml-rails) and it does basically the same: configures Slim as the template engine automatically for your rails app.
3
+ slim-rails provides Slim generators for Rails 3 and 4. It was based on
4
+ [haml-rails](http://github.com/indirect/haml-rails) and it does basically the
5
+ same:
6
+
7
+ * Any time you generate a controller or scaffold, you'll get Slim templates
8
+ (instead of ERB)
9
+ * When your Rails application loads, Slim will be loaded and initialized
10
+ automatically
11
+ * Slim templates will be respected by the view template cache digestor
12
+
4
13
  To use it, add this line to your Gemfile:
5
14
 
6
- gem "slim-rails"
15
+ ```ruby
16
+ gem "slim-rails"
17
+ ```
7
18
 
8
19
  And that's it.
9
20
 
10
21
  From the version 0.2.0, there is no need to include gem "slim" in your Gemfile.
11
22
 
12
- Every time you generate a controller or scaffold, you'll get Slim templates.
23
+ Every time you generate a controller or scaffold, you'll get Slim templates.
data/lib/slim-rails.rb CHANGED
@@ -9,6 +9,31 @@ module Slim
9
9
  else
10
10
  config.generators.template_engine :slim
11
11
  end
12
+
13
+ initializer 'slim_rails.configure_template_digestor' do
14
+ ActiveSupport.on_load(:action_view) do
15
+ ActiveSupport.on_load(:after_initialize) do
16
+ begin
17
+ if defined?(CacheDigests::DependencyTracker)
18
+ # 'cache_digests' gem being used (overrides Rails 4 implementation)
19
+ CacheDigests::DependencyTracker.register_tracker :slim, CacheDigests::DependencyTracker::ERBTracker
20
+
21
+ if ::Rails.env.development?
22
+ # recalculate cache digest keys for each request
23
+ CacheDigests::TemplateDigestor.cache = ActiveSupport::Cache::NullStore.new
24
+ end
25
+ elsif ::Rails.version.to_s >= '4.0'
26
+ # will only apply if Rails 4, which includes 'action_view/dependency_tracker'
27
+ require 'action_view/dependency_tracker'
28
+ ActionView::DependencyTracker.register_tracker :slim, ActionView::DependencyTracker::ERBTracker
29
+ ActionView::Base.cache_template_loading = false if ::Rails.env.development?
30
+ end
31
+ rescue
32
+ # likely this version of Rails doesn't support dependency tracking
33
+ end
34
+ end
35
+ end
36
+ end
12
37
  end
13
38
  end
14
39
  end
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  module Rails
3
- VERSION = "2.0.4"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slim-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-05 00:00:00.000000000 Z
12
+ date: 2014-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake