quintype-liquid 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quintype/liquid.rb +3 -1
- data/lib/quintype/liquid/file_system.rb +9 -9
- data/lib/quintype/liquid/railtie.rb +2 -2
- data/lib/quintype/liquid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9dc51862140d4bdffaf91ce3851e588b000eab3
|
4
|
+
data.tar.gz: 87592a5280a1fbebb546999710c8f6b9a25b6980
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dbeccf50c78d2b7af979696e755904d0f7eb49fe672eff1898f8e18ffcfa3a71f7e9685c655c2d29c76a67ae09eb70e5dfa84af3717a584e390b7fcfe8e6552
|
7
|
+
data.tar.gz: 6e12889b0da66f4ea18bb2ea61821f657dde095c4fd774208debeed5001af1235dee37c3b100f52e85be867d6c7edf2b5f3812aa00d485c284b4f90ef45b4caf
|
data/lib/quintype/liquid.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
module Quintype::Liquid
|
2
2
|
class FileSystem < ::Liquid::LocalFileSystem
|
3
|
-
def caching_enabled?
|
4
|
-
Rails.env.production?
|
5
|
-
end
|
6
|
-
|
7
3
|
def read_file(path)
|
8
4
|
full_path = full_path(path)
|
9
5
|
File.read(full_path) if File.exists?(full_path)
|
10
6
|
end
|
11
7
|
|
8
|
+
def read_file_with_caching(path)
|
9
|
+
@cached_templates ||= Concurrent::Map.new do |m, path|
|
10
|
+
m[path] = read_file_without_caching(path)
|
11
|
+
end
|
12
|
+
@cached_templates[path]
|
13
|
+
end
|
14
|
+
alias_method_chain :read_file, :caching if defined?(Rails) && Rails.env.production?
|
15
|
+
|
12
16
|
def read_template_file(template_path, context)
|
13
17
|
controller = context.registers[:controller]
|
14
18
|
controller_path = controller.controller_path
|
@@ -20,7 +24,7 @@ module Quintype::Liquid
|
|
20
24
|
path = template_path.include?('/') ? template_path : "#{controller_path}/#{template_path}"
|
21
25
|
path = path + format
|
22
26
|
|
23
|
-
file =
|
27
|
+
file = read_file(path)
|
24
28
|
|
25
29
|
break if file
|
26
30
|
end
|
@@ -43,9 +47,5 @@ module Quintype::Liquid
|
|
43
47
|
|
44
48
|
full_path
|
45
49
|
end
|
46
|
-
|
47
|
-
def cache_path(path)
|
48
|
-
"liquid:#{path}"
|
49
|
-
end
|
50
50
|
end
|
51
51
|
end
|
@@ -6,12 +6,12 @@ module Quintype::Liquid
|
|
6
6
|
end
|
7
7
|
|
8
8
|
initializer "quintype-liquid.liquid-file-system" do |app|
|
9
|
-
template_path =
|
9
|
+
template_path = Rails.root.join('app/views')
|
10
10
|
::Liquid::Template.file_system = Quintype::Liquid::FileSystem.new(template_path)
|
11
11
|
end
|
12
12
|
|
13
13
|
initializer "quintype-liquid.fix-caching" do |app|
|
14
|
-
::Liquid::Rails::TemplateHandler.send(:prepend, Quintype::Liquid::LiquidTemplateCachingModule)
|
14
|
+
::Liquid::Rails::TemplateHandler.send(:prepend, Quintype::Liquid::LiquidTemplateCachingModule) unless Rails.env.development?
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|