nanoc-conref-fs 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/nanoc-conref-fs/conrefifier.rb +13 -22
- data/nanoc-conref-fs.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d01c92aa582b947c2845c60898017b6ef47c30e
|
4
|
+
data.tar.gz: 2ecb11916d271d8ee34291c028dcd3bf7937fc38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdd96dbbb9abb7498a45cbc4821fb0690f648ac85c565ff5335c5bb046853cef50975631fc261bf39e941bc2b69bf8e9a02fa4c997347480e6d6125bed582596
|
7
|
+
data.tar.gz: 289b1f20ed550fbad9fd8b9a0536714252a99e5f1ef6eb85857c9163f4c6d6d6b0f6ac06039f9cfa1a84fa1973655ba66944183a36d9aa455f5e55e9e3fb7b37
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ data_sources:
|
|
25
25
|
- :X
|
26
26
|
```
|
27
27
|
|
28
|
+
You can add `filter :'conref-fs-filter'` to any of your `compile` Rules to then have them renderer through the conref processor.
|
29
|
+
|
28
30
|
**NOTE:** If you use this library with Nanoc's ERB filter, and want to use `render`, you'll need to monkey-patch an alias to avoid conflicts with Liquid:
|
29
31
|
|
30
32
|
``` ruby
|
@@ -4,36 +4,27 @@ module NanocConrefFS
|
|
4
4
|
module Conrefifier
|
5
5
|
SINGLE_SUB = /(\{\{[^\}]+\}\})/m
|
6
6
|
BLOCK_SUB = /\{% (?:if|unless).+? %\}.*?\{% end(?:if|unless) %\}/m
|
7
|
-
PATH_TO_VARS = {}
|
8
7
|
|
9
8
|
def self.file_variables(variables, path, rep)
|
10
9
|
return {} if variables.nil?
|
11
10
|
|
12
11
|
data_vars = {}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
scopes = variables.select do |v|
|
14
|
+
scope_block = v[:scope]
|
15
|
+
scoped_path = scope_block[:path].empty? || Regexp.new(scope_block[:path]) =~ path
|
16
|
+
scoped_rep = scope_block[:reps].nil? || scope_block[:reps].include?(rep)
|
17
|
+
scoped_path && scoped_rep
|
18
|
+
end
|
19
|
+
|
20
|
+
# I benchmarked that assignment is much
|
21
|
+
# faster than merging an empty hash
|
22
|
+
if scopes.length == 1
|
23
|
+
data_vars = scopes.first[:values]
|
18
24
|
else
|
19
|
-
scopes
|
20
|
-
|
21
|
-
scoped_path = scope_block[:path].empty? || Regexp.new(scope_block[:path]) =~ path
|
22
|
-
scoped_rep = scope_block[:reps].nil? || scope_block[:reps].include?(rep)
|
23
|
-
scoped_path && scoped_rep
|
24
|
-
end
|
25
|
-
# I benchmarked that assignment is much faster than
|
26
|
-
# merging an empty hash
|
27
|
-
if scopes.length == 1
|
28
|
-
data_vars = scopes.first[:values]
|
29
|
-
else
|
30
|
-
scopes.each do |scope|
|
31
|
-
data_vars = data_vars.merge(scope[:values])
|
32
|
-
end
|
25
|
+
scopes.each do |scope|
|
26
|
+
data_vars = data_vars.merge(scope[:values])
|
33
27
|
end
|
34
|
-
# stash for later use
|
35
|
-
PATH_TO_VARS[rep] = {}
|
36
|
-
PATH_TO_VARS[rep][path] = data_vars
|
37
28
|
end
|
38
29
|
|
39
30
|
data_vars
|
data/nanoc-conref-fs.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = 'nanoc-conref-fs'
|
6
|
-
spec.version = '0.6.
|
6
|
+
spec.version = '0.6.2'
|
7
7
|
spec.authors = ['Garen Torikian']
|
8
8
|
spec.email = ['gjtorikian@gmail.com']
|
9
9
|
spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-conref-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|