locomotivecms-liquid 4.0.0.alpha → 4.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/liquid/tags/inherited_block.rb +13 -6
- data/lib/liquid/version.rb +1 -1
- data/test/integration/tags/extends_tag_test.rb +5 -0
- 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: 9146b6c0f563f43a00efbd5656d8642c0cc356b0
|
4
|
+
data.tar.gz: 5f181a813cd6c5df89507c7d5e0c2dd31c4e378b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 062c89b8f9c5b313705384a2cb16886d87ce8a483546099c0b78fb0da0a339b4de6997a0fbab2f234b62c057451cc7114bacb01b9b2ab6fc3592d704ff1a8300
|
7
|
+
data.tar.gz: 2ade61abd56b055a10feb20de21f58a1cc2152c94c10408f024cb3d2879b2a9ccf9ab70e666dad3708396ca046a68265c345d973d28ef909f4fb9d5480bd7444
|
@@ -29,33 +29,33 @@ module Liquid
|
|
29
29
|
|
30
30
|
def prepare_for_inheritance
|
31
31
|
# give a different name if this is a nested block
|
32
|
-
if block =
|
32
|
+
if block = inherited_blocks[:nested].last
|
33
33
|
@name = "#{block.name}/#{@name}"
|
34
34
|
end
|
35
35
|
|
36
36
|
# append this block to the stack in order to
|
37
37
|
# get a name for the other nested inherited blocks
|
38
|
-
|
38
|
+
inherited_blocks[:nested].push(self)
|
39
39
|
|
40
40
|
# build the linked chain of inherited blocks
|
41
41
|
# make a link with the descendant and the parent (chained list)
|
42
|
-
if descendant =
|
42
|
+
if descendant = inherited_blocks[:all][@name]
|
43
43
|
self.descendant = descendant
|
44
44
|
descendant.parent = self
|
45
45
|
|
46
46
|
# get the value of the blank property from the descendant
|
47
|
-
@blank = descendant.blank?
|
47
|
+
@blank = descendant.blank?
|
48
48
|
end
|
49
49
|
|
50
50
|
# become the descendant of the inherited block from the parent template
|
51
|
-
|
51
|
+
inherited_blocks[:all][@name] = self
|
52
52
|
end
|
53
53
|
|
54
54
|
def parse(tokens)
|
55
55
|
super
|
56
56
|
|
57
57
|
# when the parsing of the block is done, we can then remove it from the stack
|
58
|
-
|
58
|
+
inherited_blocks[:nested].pop
|
59
59
|
end
|
60
60
|
|
61
61
|
alias_method :render_without_inheritance, :render
|
@@ -93,6 +93,13 @@ module Liquid
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
def inherited_blocks
|
97
|
+
options[:inherited_blocks] || {
|
98
|
+
all: {},
|
99
|
+
nested: []
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
96
103
|
end
|
97
104
|
|
98
105
|
Template.register_tag('block', InheritedBlock)
|
data/lib/liquid/version.rb
CHANGED
@@ -34,6 +34,11 @@ class ExtendsTagTest < Minitest::Test
|
|
34
34
|
Liquid::Template.file_system = LayoutFileSystem.new
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_template_with_a_block
|
38
|
+
assert_template_result "<body><h1>Hello</h1><p>Lorem ipsum</p></body>",
|
39
|
+
Liquid::Template.file_system.read_template_file('page_with_title', nil)
|
40
|
+
end
|
41
|
+
|
37
42
|
def test_template_extends_another_template
|
38
43
|
assert_template_result "<body>base</body>",
|
39
44
|
"{% extends base %}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms-liquid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|