liquid 3.0.0 → 4.0.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.
- checksums.yaml +4 -4
- data/History.md +130 -62
- data/README.md +31 -0
- data/lib/liquid/block.rb +31 -124
- data/lib/liquid/block_body.rb +75 -59
- data/lib/liquid/condition.rb +23 -22
- data/lib/liquid/context.rb +51 -60
- data/lib/liquid/document.rb +19 -9
- data/lib/liquid/drop.rb +17 -16
- data/lib/liquid/errors.rb +20 -24
- data/lib/liquid/expression.rb +15 -3
- data/lib/liquid/extensions.rb +13 -7
- data/lib/liquid/file_system.rb +11 -11
- data/lib/liquid/forloop_drop.rb +42 -0
- data/lib/liquid/i18n.rb +5 -5
- data/lib/liquid/interrupts.rb +1 -2
- data/lib/liquid/lexer.rb +6 -4
- data/lib/liquid/locales/en.yml +5 -1
- data/lib/liquid/parse_context.rb +37 -0
- data/lib/liquid/parser.rb +1 -1
- data/lib/liquid/parser_switching.rb +4 -4
- data/lib/liquid/profiler/hooks.rb +7 -7
- data/lib/liquid/profiler.rb +18 -19
- data/lib/liquid/range_lookup.rb +16 -1
- data/lib/liquid/resource_limits.rb +23 -0
- data/lib/liquid/standardfilters.rb +121 -61
- data/lib/liquid/strainer.rb +32 -29
- data/lib/liquid/tablerowloop_drop.rb +62 -0
- data/lib/liquid/tag.rb +9 -8
- data/lib/liquid/tags/assign.rb +17 -4
- data/lib/liquid/tags/break.rb +0 -3
- data/lib/liquid/tags/capture.rb +2 -2
- data/lib/liquid/tags/case.rb +19 -12
- data/lib/liquid/tags/comment.rb +2 -2
- data/lib/liquid/tags/cycle.rb +6 -6
- data/lib/liquid/tags/decrement.rb +1 -4
- data/lib/liquid/tags/for.rb +95 -75
- data/lib/liquid/tags/if.rb +48 -43
- data/lib/liquid/tags/ifchanged.rb +0 -2
- data/lib/liquid/tags/include.rb +61 -52
- data/lib/liquid/tags/raw.rb +32 -4
- data/lib/liquid/tags/table_row.rb +12 -31
- data/lib/liquid/tags/unless.rb +4 -5
- data/lib/liquid/template.rb +42 -54
- data/lib/liquid/tokenizer.rb +31 -0
- data/lib/liquid/utils.rb +52 -8
- data/lib/liquid/variable.rb +46 -45
- data/lib/liquid/variable_lookup.rb +9 -5
- data/lib/liquid/version.rb +1 -1
- data/lib/liquid.rb +9 -7
- data/test/integration/assign_test.rb +18 -8
- data/test/integration/blank_test.rb +14 -14
- data/test/integration/capture_test.rb +10 -0
- data/test/integration/context_test.rb +2 -2
- data/test/integration/document_test.rb +19 -0
- data/test/integration/drop_test.rb +42 -40
- data/test/integration/error_handling_test.rb +99 -46
- data/test/integration/filter_test.rb +72 -19
- data/test/integration/hash_ordering_test.rb +9 -9
- data/test/integration/output_test.rb +34 -27
- data/test/integration/parsing_quirks_test.rb +15 -13
- data/test/integration/render_profiling_test.rb +20 -20
- data/test/integration/security_test.rb +9 -7
- data/test/integration/standard_filter_test.rb +198 -42
- data/test/integration/tags/break_tag_test.rb +1 -2
- data/test/integration/tags/continue_tag_test.rb +0 -1
- data/test/integration/tags/for_tag_test.rb +133 -98
- data/test/integration/tags/if_else_tag_test.rb +96 -77
- data/test/integration/tags/include_tag_test.rb +34 -30
- data/test/integration/tags/increment_tag_test.rb +10 -11
- data/test/integration/tags/raw_tag_test.rb +7 -1
- data/test/integration/tags/standard_tag_test.rb +121 -122
- data/test/integration/tags/statements_test.rb +3 -5
- data/test/integration/tags/table_row_test.rb +20 -19
- data/test/integration/tags/unless_else_tag_test.rb +6 -6
- data/test/integration/template_test.rb +190 -49
- data/test/integration/trim_mode_test.rb +525 -0
- data/test/integration/variable_test.rb +23 -13
- data/test/test_helper.rb +44 -9
- data/test/unit/block_unit_test.rb +8 -5
- data/test/unit/condition_unit_test.rb +86 -77
- data/test/unit/context_unit_test.rb +48 -57
- data/test/unit/file_system_unit_test.rb +3 -3
- data/test/unit/i18n_unit_test.rb +2 -2
- data/test/unit/lexer_unit_test.rb +11 -8
- data/test/unit/parser_unit_test.rb +2 -2
- data/test/unit/regexp_unit_test.rb +1 -1
- data/test/unit/strainer_unit_test.rb +85 -8
- data/test/unit/tag_unit_test.rb +7 -2
- data/test/unit/tags/case_tag_unit_test.rb +1 -1
- data/test/unit/tags/for_tag_unit_test.rb +2 -2
- data/test/unit/tags/if_tag_unit_test.rb +1 -1
- data/test/unit/template_unit_test.rb +14 -5
- data/test/unit/tokenizer_unit_test.rb +24 -7
- data/test/unit/variable_unit_test.rb +66 -43
- metadata +55 -50
- data/lib/liquid/module_ex.rb +0 -62
- data/lib/liquid/token.rb +0 -18
- data/test/unit/module_ex_unit_test.rb +0 -87
- /data/{MIT-LICENSE → LICENSE} +0 -0
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Tobias
|
7
|
+
- Tobias Lütke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '11.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '11.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,7 +48,7 @@ extra_rdoc_files:
|
|
48
48
|
- README.md
|
49
49
|
files:
|
50
50
|
- History.md
|
51
|
-
-
|
51
|
+
- LICENSE
|
52
52
|
- README.md
|
53
53
|
- lib/liquid.rb
|
54
54
|
- lib/liquid/block.rb
|
@@ -61,18 +61,21 @@ files:
|
|
61
61
|
- lib/liquid/expression.rb
|
62
62
|
- lib/liquid/extensions.rb
|
63
63
|
- lib/liquid/file_system.rb
|
64
|
+
- lib/liquid/forloop_drop.rb
|
64
65
|
- lib/liquid/i18n.rb
|
65
66
|
- lib/liquid/interrupts.rb
|
66
67
|
- lib/liquid/lexer.rb
|
67
68
|
- lib/liquid/locales/en.yml
|
68
|
-
- lib/liquid/
|
69
|
+
- lib/liquid/parse_context.rb
|
69
70
|
- lib/liquid/parser.rb
|
70
71
|
- lib/liquid/parser_switching.rb
|
71
72
|
- lib/liquid/profiler.rb
|
72
73
|
- lib/liquid/profiler/hooks.rb
|
73
74
|
- lib/liquid/range_lookup.rb
|
75
|
+
- lib/liquid/resource_limits.rb
|
74
76
|
- lib/liquid/standardfilters.rb
|
75
77
|
- lib/liquid/strainer.rb
|
78
|
+
- lib/liquid/tablerowloop_drop.rb
|
76
79
|
- lib/liquid/tag.rb
|
77
80
|
- lib/liquid/tags/assign.rb
|
78
81
|
- lib/liquid/tags/break.rb
|
@@ -91,7 +94,7 @@ files:
|
|
91
94
|
- lib/liquid/tags/table_row.rb
|
92
95
|
- lib/liquid/tags/unless.rb
|
93
96
|
- lib/liquid/template.rb
|
94
|
-
- lib/liquid/
|
97
|
+
- lib/liquid/tokenizer.rb
|
95
98
|
- lib/liquid/utils.rb
|
96
99
|
- lib/liquid/variable.rb
|
97
100
|
- lib/liquid/variable_lookup.rb
|
@@ -101,6 +104,7 @@ files:
|
|
101
104
|
- test/integration/blank_test.rb
|
102
105
|
- test/integration/capture_test.rb
|
103
106
|
- test/integration/context_test.rb
|
107
|
+
- test/integration/document_test.rb
|
104
108
|
- test/integration/drop_test.rb
|
105
109
|
- test/integration/error_handling_test.rb
|
106
110
|
- test/integration/filter_test.rb
|
@@ -122,6 +126,7 @@ files:
|
|
122
126
|
- test/integration/tags/table_row_test.rb
|
123
127
|
- test/integration/tags/unless_else_tag_test.rb
|
124
128
|
- test/integration/template_test.rb
|
129
|
+
- test/integration/trim_mode_test.rb
|
125
130
|
- test/integration/variable_test.rb
|
126
131
|
- test/test_helper.rb
|
127
132
|
- test/unit/block_unit_test.rb
|
@@ -130,7 +135,6 @@ files:
|
|
130
135
|
- test/unit/file_system_unit_test.rb
|
131
136
|
- test/unit/i18n_unit_test.rb
|
132
137
|
- test/unit/lexer_unit_test.rb
|
133
|
-
- test/unit/module_ex_unit_test.rb
|
134
138
|
- test/unit/parser_unit_test.rb
|
135
139
|
- test/unit/regexp_unit_test.rb
|
136
140
|
- test/unit/strainer_unit_test.rb
|
@@ -153,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
157
|
requirements:
|
154
158
|
- - ">="
|
155
159
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
160
|
+
version: 2.1.0
|
157
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
162
|
requirements:
|
159
163
|
- - ">="
|
@@ -161,53 +165,54 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
165
|
version: 1.3.7
|
162
166
|
requirements: []
|
163
167
|
rubyforge_project:
|
164
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.4.5
|
165
169
|
signing_key:
|
166
170
|
specification_version: 4
|
167
171
|
summary: A secure, non-evaling end user template engine with aesthetic markup.
|
168
172
|
test_files:
|
169
|
-
- test/
|
170
|
-
- test/
|
171
|
-
- test/
|
172
|
-
- test/
|
173
|
-
- test/
|
174
|
-
- test/
|
175
|
-
- test/
|
176
|
-
- test/
|
177
|
-
- test/
|
178
|
-
- test/
|
179
|
-
- test/
|
180
|
-
- test/
|
181
|
-
- test/
|
182
|
-
- test/
|
183
|
-
- test/
|
184
|
-
- test/
|
185
|
-
- test/
|
186
|
-
- test/test_helper.rb
|
173
|
+
- test/fixtures/en_locale.yml
|
174
|
+
- test/integration/assign_test.rb
|
175
|
+
- test/integration/blank_test.rb
|
176
|
+
- test/integration/capture_test.rb
|
177
|
+
- test/integration/context_test.rb
|
178
|
+
- test/integration/document_test.rb
|
179
|
+
- test/integration/drop_test.rb
|
180
|
+
- test/integration/error_handling_test.rb
|
181
|
+
- test/integration/filter_test.rb
|
182
|
+
- test/integration/hash_ordering_test.rb
|
183
|
+
- test/integration/output_test.rb
|
184
|
+
- test/integration/parsing_quirks_test.rb
|
185
|
+
- test/integration/render_profiling_test.rb
|
186
|
+
- test/integration/security_test.rb
|
187
|
+
- test/integration/standard_filter_test.rb
|
188
|
+
- test/integration/tags/break_tag_test.rb
|
189
|
+
- test/integration/tags/continue_tag_test.rb
|
187
190
|
- test/integration/tags/for_tag_test.rb
|
188
191
|
- test/integration/tags/if_else_tag_test.rb
|
189
192
|
- test/integration/tags/include_tag_test.rb
|
190
|
-
- test/integration/tags/
|
193
|
+
- test/integration/tags/increment_tag_test.rb
|
191
194
|
- test/integration/tags/raw_tag_test.rb
|
192
|
-
- test/integration/tags/table_row_test.rb
|
193
195
|
- test/integration/tags/standard_tag_test.rb
|
194
|
-
- test/integration/tags/increment_tag_test.rb
|
195
|
-
- test/integration/tags/unless_else_tag_test.rb
|
196
196
|
- test/integration/tags/statements_test.rb
|
197
|
-
- test/integration/tags/
|
198
|
-
- test/integration/
|
199
|
-
- test/integration/render_profiling_test.rb
|
200
|
-
- test/integration/parsing_quirks_test.rb
|
201
|
-
- test/integration/drop_test.rb
|
202
|
-
- test/integration/hash_ordering_test.rb
|
203
|
-
- test/integration/capture_test.rb
|
204
|
-
- test/integration/assign_test.rb
|
205
|
-
- test/integration/output_test.rb
|
206
|
-
- test/integration/error_handling_test.rb
|
207
|
-
- test/integration/blank_test.rb
|
197
|
+
- test/integration/tags/table_row_test.rb
|
198
|
+
- test/integration/tags/unless_else_tag_test.rb
|
208
199
|
- test/integration/template_test.rb
|
209
|
-
- test/integration/
|
200
|
+
- test/integration/trim_mode_test.rb
|
210
201
|
- test/integration/variable_test.rb
|
211
|
-
- test/
|
212
|
-
- test/
|
213
|
-
- test/
|
202
|
+
- test/test_helper.rb
|
203
|
+
- test/unit/block_unit_test.rb
|
204
|
+
- test/unit/condition_unit_test.rb
|
205
|
+
- test/unit/context_unit_test.rb
|
206
|
+
- test/unit/file_system_unit_test.rb
|
207
|
+
- test/unit/i18n_unit_test.rb
|
208
|
+
- test/unit/lexer_unit_test.rb
|
209
|
+
- test/unit/parser_unit_test.rb
|
210
|
+
- test/unit/regexp_unit_test.rb
|
211
|
+
- test/unit/strainer_unit_test.rb
|
212
|
+
- test/unit/tag_unit_test.rb
|
213
|
+
- test/unit/tags/case_tag_unit_test.rb
|
214
|
+
- test/unit/tags/for_tag_unit_test.rb
|
215
|
+
- test/unit/tags/if_tag_unit_test.rb
|
216
|
+
- test/unit/template_unit_test.rb
|
217
|
+
- test/unit/tokenizer_unit_test.rb
|
218
|
+
- test/unit/variable_unit_test.rb
|
data/lib/liquid/module_ex.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright 2007 by Domizio Demichelis
|
2
|
-
# This library is free software. It may be used, redistributed and/or modified
|
3
|
-
# under the same terms as Ruby itself
|
4
|
-
#
|
5
|
-
# This extension is used in order to expose the object of the implementing class
|
6
|
-
# to liquid as it were a Drop. It also limits the liquid-callable methods of the instance
|
7
|
-
# to the allowed method passed with the liquid_methods call
|
8
|
-
# Example:
|
9
|
-
#
|
10
|
-
# class SomeClass
|
11
|
-
# liquid_methods :an_allowed_method
|
12
|
-
#
|
13
|
-
# def an_allowed_method
|
14
|
-
# 'this comes from an allowed method'
|
15
|
-
# end
|
16
|
-
# def unallowed_method
|
17
|
-
# 'this will never be an output'
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# if you want to extend the drop to other methods you can defines more methods
|
22
|
-
# in the class <YourClass>::LiquidDropClass
|
23
|
-
#
|
24
|
-
# class SomeClass::LiquidDropClass
|
25
|
-
# def another_allowed_method
|
26
|
-
# 'and this from another allowed method'
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
#
|
31
|
-
# usage:
|
32
|
-
# @something = SomeClass.new
|
33
|
-
#
|
34
|
-
# template:
|
35
|
-
# {{something.an_allowed_method}}{{something.unallowed_method}} {{something.another_allowed_method}}
|
36
|
-
#
|
37
|
-
# output:
|
38
|
-
# 'this comes from an allowed method and this from another allowed method'
|
39
|
-
#
|
40
|
-
# You can also chain associations, by adding the liquid_method call in the
|
41
|
-
# association models.
|
42
|
-
#
|
43
|
-
class Module
|
44
|
-
|
45
|
-
def liquid_methods(*allowed_methods)
|
46
|
-
drop_class = eval "class #{self.to_s}::LiquidDropClass < Liquid::Drop; self; end"
|
47
|
-
define_method :to_liquid do
|
48
|
-
drop_class.new(self)
|
49
|
-
end
|
50
|
-
drop_class.class_eval do
|
51
|
-
def initialize(object)
|
52
|
-
@object = object
|
53
|
-
end
|
54
|
-
allowed_methods.each do |sym|
|
55
|
-
define_method sym do
|
56
|
-
@object.send sym
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
data/lib/liquid/token.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Liquid
|
2
|
-
class Token < String
|
3
|
-
attr_reader :line_number
|
4
|
-
|
5
|
-
def initialize(content, line_number)
|
6
|
-
super(content)
|
7
|
-
@line_number = line_number
|
8
|
-
end
|
9
|
-
|
10
|
-
def raw
|
11
|
-
"<raw>"
|
12
|
-
end
|
13
|
-
|
14
|
-
def child(string)
|
15
|
-
Token.new(string, @line_number)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TestClassA
|
4
|
-
liquid_methods :allowedA, :chainedB
|
5
|
-
def allowedA
|
6
|
-
'allowedA'
|
7
|
-
end
|
8
|
-
def restrictedA
|
9
|
-
'restrictedA'
|
10
|
-
end
|
11
|
-
def chainedB
|
12
|
-
TestClassB.new
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class TestClassB
|
17
|
-
liquid_methods :allowedB, :chainedC
|
18
|
-
def allowedB
|
19
|
-
'allowedB'
|
20
|
-
end
|
21
|
-
def chainedC
|
22
|
-
TestClassC.new
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
class TestClassC
|
27
|
-
liquid_methods :allowedC
|
28
|
-
def allowedC
|
29
|
-
'allowedC'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class TestClassC::LiquidDropClass
|
34
|
-
def another_allowedC
|
35
|
-
'another_allowedC'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class ModuleExUnitTest < Minitest::Test
|
40
|
-
include Liquid
|
41
|
-
|
42
|
-
def setup
|
43
|
-
@a = TestClassA.new
|
44
|
-
@b = TestClassB.new
|
45
|
-
@c = TestClassC.new
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_should_create_LiquidDropClass
|
49
|
-
assert TestClassA::LiquidDropClass
|
50
|
-
assert TestClassB::LiquidDropClass
|
51
|
-
assert TestClassC::LiquidDropClass
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_should_respond_to_liquid
|
55
|
-
assert @a.respond_to?(:to_liquid)
|
56
|
-
assert @b.respond_to?(:to_liquid)
|
57
|
-
assert @c.respond_to?(:to_liquid)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_should_return_LiquidDropClass_object
|
61
|
-
assert @a.to_liquid.is_a?(TestClassA::LiquidDropClass)
|
62
|
-
assert @b.to_liquid.is_a?(TestClassB::LiquidDropClass)
|
63
|
-
assert @c.to_liquid.is_a?(TestClassC::LiquidDropClass)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_should_respond_to_liquid_methods
|
67
|
-
assert @a.to_liquid.respond_to?(:allowedA)
|
68
|
-
assert @a.to_liquid.respond_to?(:chainedB)
|
69
|
-
assert @b.to_liquid.respond_to?(:allowedB)
|
70
|
-
assert @b.to_liquid.respond_to?(:chainedC)
|
71
|
-
assert @c.to_liquid.respond_to?(:allowedC)
|
72
|
-
assert @c.to_liquid.respond_to?(:another_allowedC)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_should_not_respond_to_restricted_methods
|
76
|
-
assert ! @a.to_liquid.respond_to?(:restricted)
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_should_use_regular_objects_as_drops
|
80
|
-
assert_template_result 'allowedA', "{{ a.allowedA }}", 'a'=>@a
|
81
|
-
assert_template_result 'allowedB', "{{ a.chainedB.allowedB }}", 'a'=>@a
|
82
|
-
assert_template_result 'allowedC', "{{ a.chainedB.chainedC.allowedC }}", 'a'=>@a
|
83
|
-
assert_template_result 'another_allowedC', "{{ a.chainedB.chainedC.another_allowedC }}", 'a'=>@a
|
84
|
-
assert_template_result '', "{{ a.restricted }}", 'a'=>@a
|
85
|
-
assert_template_result '', "{{ a.unknown }}", 'a'=>@a
|
86
|
-
end
|
87
|
-
end # ModuleExTest
|
/data/{MIT-LICENSE → LICENSE}
RENAMED
File without changes
|