curlybars 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/curlybars.rb +17 -5
- data/lib/curlybars/railtie.rb +4 -0
- data/lib/curlybars/version.rb +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52c29c45b57f92100b013838beeedfbf90786f38c53b16a80b5e8ce9c9375370
|
4
|
+
data.tar.gz: f3cb2ae061d3e34108f744ae194bbb2a73e87f189f99c672f76c29f91d330452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6506b677a75fcb692fdb89d65f959978287572a8149c77b2eb1035312a4dbd951e88cf4293a98a19da7beca6557f48c61ce5ac733d6cb37cf56c8ba17118a6bc
|
7
|
+
data.tar.gz: a3b173d94eebaac12907d143b01e8a28a07169ba23dc4c93502f452a76d95dac931c91ddb95cdd90951d8042cab73ff4c71e6181c11b5cce93598ea5216faac1
|
data/lib/curlybars.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'active_support/cache'
|
1
3
|
require 'curlybars/version'
|
2
4
|
|
3
5
|
# Curlybars is a view system based on Curly that uses Handlebars syntax.
|
@@ -23,12 +25,16 @@ module Curlybars
|
|
23
25
|
#
|
24
26
|
# Returns a String containing the Ruby code.
|
25
27
|
def compile(source, identifier = nil)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
cache_key = ["Curlybars.compile", identifier, Digest::SHA256.hexdigest(source)]
|
29
|
+
|
30
|
+
cache.fetch(cache_key) do
|
31
|
+
transformers = Curlybars.configuration.compiler_transformers
|
32
|
+
transformed_source = transformers.inject(source) do |memo, transformer|
|
33
|
+
transformer.transform(memo, identifier)
|
34
|
+
end
|
30
35
|
|
31
|
-
|
36
|
+
ast(transformed_source, identifier, run_processors: true).compile
|
37
|
+
end
|
32
38
|
end
|
33
39
|
|
34
40
|
# Validates the source against a presenter.
|
@@ -66,6 +72,12 @@ module Curlybars
|
|
66
72
|
errors.empty?
|
67
73
|
end
|
68
74
|
|
75
|
+
def cache
|
76
|
+
@cache ||= ActiveSupport::Cache::MemoryStore.new
|
77
|
+
end
|
78
|
+
|
79
|
+
attr_writer :cache
|
80
|
+
|
69
81
|
private
|
70
82
|
|
71
83
|
def ast(source, identifier, run_processors:)
|
data/lib/curlybars/railtie.rb
CHANGED
@@ -7,6 +7,10 @@ module Curlybars
|
|
7
7
|
ActionView::Template.register_template_handler(:hbs, Curlybars::TemplateHandler)
|
8
8
|
end
|
9
9
|
|
10
|
+
initializer 'curlybars.set_cache' do
|
11
|
+
Curlybars.cache = Rails.cache
|
12
|
+
end
|
13
|
+
|
10
14
|
if defined?(CacheDigests::DependencyTracker)
|
11
15
|
CacheDigests::DependencyTracker.register_tracker :hbs, Curlybars::DependencyTracker
|
12
16
|
end
|
data/lib/curlybars/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curlybars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Libo Cannici
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2018-
|
16
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: actionpack
|
@@ -35,6 +35,26 @@ dependencies:
|
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '6.0'
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: activesupport
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '4.2'
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.2'
|
55
|
+
- - "<"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '6.0'
|
38
58
|
- !ruby/object:Gem::Dependency
|
39
59
|
name: ffi
|
40
60
|
requirement: !ruby/object:Gem::Requirement
|