liquid 5.9.0 → 5.11.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 +7 -0
- data/README.md +4 -4
- data/lib/liquid/context.rb +1 -1
- data/lib/liquid/environment.rb +1 -1
- data/lib/liquid/parse_context.rb +4 -4
- data/lib/liquid/parser_switching.rb +18 -10
- data/lib/liquid/tags/case.rb +4 -4
- data/lib/liquid/tags/cycle.rb +1 -1
- data/lib/liquid/tags/for.rb +1 -1
- data/lib/liquid/tags/if.rb +1 -1
- data/lib/liquid/tags/include.rb +1 -1
- data/lib/liquid/tags/render.rb +3 -3
- data/lib/liquid/tags/table_row.rb +1 -1
- data/lib/liquid/template.rb +1 -1
- data/lib/liquid/variable.rb +3 -3
- data/lib/liquid/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 88705bb2e645a541fb76afe0a59c727429aaae33824103fb94178b5edbbda54e
|
|
4
|
+
data.tar.gz: 5982801da2e3431575b2e32edfd0f46a3371b1c74060dc8936470df75c27c630
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9c8ddeba605175a534a658c96dc749624ce78171f3df420011b3ac0f525301b29dac63b452e07081a8355f231e4643ee49a087daf0bcf0bb550bf07726c17228
|
|
7
|
+
data.tar.gz: 150dce06c67bc6aa2efddf094e6b2b745b58503436fcfa8784f0f1d88f2d8447f2b8a025915745a5b0b31109b3a8e0887b552e7a7279ff3cb123182ae4188543
|
data/History.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Liquid Change Log
|
|
2
2
|
|
|
3
|
+
## 5.11.0
|
|
4
|
+
* Revert the Inline Snippets tag (#2001), treat its inclusion in the latest Liquid release as a bug, and allow for feedback on RFC#1916 to better support Liquid developers [Guilherme Carreiro]
|
|
5
|
+
* Rename the `:rigid` error mode to `:strict2` and display a warning when users attempt to use the `:rigid` mode [Guilherme Carreiro]
|
|
6
|
+
|
|
7
|
+
## 5.10.0
|
|
8
|
+
* Introduce support for Inline Snippets [Julia Boutin]
|
|
9
|
+
|
|
3
10
|
## 5.9.0
|
|
4
11
|
* Introduce `:rigid` error mode for stricter, safer parsing of all tags [CP Clermont, Guilherme Carreiro]
|
|
5
12
|
|
data/README.md
CHANGED
|
@@ -103,10 +103,10 @@ Liquid also comes with different parsers that can be used when editing templates
|
|
|
103
103
|
when templates are invalid. You can enable this new parser like this:
|
|
104
104
|
|
|
105
105
|
```ruby
|
|
106
|
-
Liquid::Environment.default.error_mode = :
|
|
107
|
-
Liquid::Environment.default.error_mode = :strict
|
|
108
|
-
Liquid::Environment.default.error_mode = :warn
|
|
109
|
-
Liquid::Environment.default.error_mode = :lax
|
|
106
|
+
Liquid::Environment.default.error_mode = :strict2 # Raises a SyntaxError when invalid syntax is used in all tags
|
|
107
|
+
Liquid::Environment.default.error_mode = :strict # Raises a SyntaxError when invalid syntax is used in some tags
|
|
108
|
+
Liquid::Environment.default.error_mode = :warn # Adds strict errors to template.errors but continues as normal
|
|
109
|
+
Liquid::Environment.default.error_mode = :lax # The default mode, accepts almost anything.
|
|
110
110
|
```
|
|
111
111
|
|
|
112
112
|
If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`:
|
data/lib/liquid/context.rb
CHANGED
data/lib/liquid/environment.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Liquid
|
|
|
34
34
|
# @param file_system The default file system that is used
|
|
35
35
|
# to load templates from.
|
|
36
36
|
# @param error_mode [Symbol] The default error mode for all templates
|
|
37
|
-
# (either :
|
|
37
|
+
# (either :strict2, :strict, :warn, or :lax).
|
|
38
38
|
# @param exception_renderer [Proc] The exception renderer that is used to
|
|
39
39
|
# render exceptions.
|
|
40
40
|
# @yieldparam environment [Environment] The environment instance that is being built.
|
data/lib/liquid/parse_context.rb
CHANGED
|
@@ -55,15 +55,15 @@ module Liquid
|
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def parse_expression(markup, safe: false)
|
|
58
|
-
if !safe && @error_mode == :
|
|
58
|
+
if !safe && @error_mode == :strict2
|
|
59
59
|
# parse_expression is a widely used API. To maintain backward
|
|
60
|
-
# compatibility while raising awareness about
|
|
60
|
+
# compatibility while raising awareness about strict2 parser standards,
|
|
61
61
|
# the safe flag supports API users make a deliberate decision.
|
|
62
62
|
#
|
|
63
|
-
# In
|
|
63
|
+
# In strict2 mode, markup MUST come from a string returned by the parser
|
|
64
64
|
# (e.g., parser.expression). We're not calling the parser here to
|
|
65
65
|
# prevent redundant parser overhead.
|
|
66
|
-
raise Liquid::InternalError, "unsafe parse_expression cannot be used in
|
|
66
|
+
raise Liquid::InternalError, "unsafe parse_expression cannot be used in strict2 mode"
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
Expression.parse(markup, @string_scanner, @expression_cache)
|
|
@@ -7,16 +7,19 @@ module Liquid
|
|
|
7
7
|
# It's basically doing the same thing the {#parse_with_selected_parser},
|
|
8
8
|
# except this will try the strict parser regardless of the error mode,
|
|
9
9
|
# and fall back to the lax parser if the error mode is lax or warn,
|
|
10
|
-
# except when in
|
|
10
|
+
# except when in strict2 mode where it uses the strict2 parser.
|
|
11
11
|
#
|
|
12
12
|
# @deprecated Use {#parse_with_selected_parser} instead.
|
|
13
13
|
def strict_parse_with_error_mode_fallback(markup)
|
|
14
|
-
return
|
|
14
|
+
return strict2_parse_with_error_context(markup) if strict2_mode?
|
|
15
15
|
|
|
16
16
|
strict_parse_with_error_context(markup)
|
|
17
17
|
rescue SyntaxError => e
|
|
18
18
|
case parse_context.error_mode
|
|
19
19
|
when :rigid
|
|
20
|
+
rigid_warn
|
|
21
|
+
raise
|
|
22
|
+
when :strict2
|
|
20
23
|
raise
|
|
21
24
|
when :strict
|
|
22
25
|
raise
|
|
@@ -28,12 +31,13 @@ module Liquid
|
|
|
28
31
|
|
|
29
32
|
def parse_with_selected_parser(markup)
|
|
30
33
|
case parse_context.error_mode
|
|
31
|
-
when :rigid
|
|
32
|
-
when :
|
|
33
|
-
when :
|
|
34
|
+
when :rigid then rigid_warn && strict2_parse_with_error_context(markup)
|
|
35
|
+
when :strict2 then strict2_parse_with_error_context(markup)
|
|
36
|
+
when :strict then strict_parse_with_error_context(markup)
|
|
37
|
+
when :lax then lax_parse(markup)
|
|
34
38
|
when :warn
|
|
35
39
|
begin
|
|
36
|
-
|
|
40
|
+
strict2_parse_with_error_context(markup)
|
|
37
41
|
rescue SyntaxError => e
|
|
38
42
|
parse_context.warnings << e
|
|
39
43
|
lax_parse(markup)
|
|
@@ -41,14 +45,18 @@ module Liquid
|
|
|
41
45
|
end
|
|
42
46
|
end
|
|
43
47
|
|
|
44
|
-
def
|
|
45
|
-
parse_context.error_mode == :rigid
|
|
48
|
+
def strict2_mode?
|
|
49
|
+
parse_context.error_mode == :strict2 || parse_context.error_mode == :rigid
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
private
|
|
49
53
|
|
|
50
|
-
def
|
|
51
|
-
|
|
54
|
+
def rigid_warn
|
|
55
|
+
Deprecations.warn(':rigid', ':strict2')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def strict2_parse_with_error_context(markup)
|
|
59
|
+
strict2_parse(markup)
|
|
52
60
|
rescue SyntaxError => e
|
|
53
61
|
e.line_number = line_number
|
|
54
62
|
e.markup_context = markup_context(markup)
|
data/lib/liquid/tags/case.rb
CHANGED
|
@@ -86,7 +86,7 @@ module Liquid
|
|
|
86
86
|
|
|
87
87
|
private
|
|
88
88
|
|
|
89
|
-
def
|
|
89
|
+
def strict2_parse(markup)
|
|
90
90
|
parser = @parse_context.new_parser(markup)
|
|
91
91
|
@left = safe_parse_expression(parser)
|
|
92
92
|
parser.consume(:end_of_string)
|
|
@@ -107,14 +107,14 @@ module Liquid
|
|
|
107
107
|
def record_when_condition(markup)
|
|
108
108
|
body = new_body
|
|
109
109
|
|
|
110
|
-
if
|
|
111
|
-
|
|
110
|
+
if strict2_mode?
|
|
111
|
+
parse_strict2_when(markup, body)
|
|
112
112
|
else
|
|
113
113
|
parse_lax_when(markup, body)
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
-
def
|
|
117
|
+
def parse_strict2_when(markup, body)
|
|
118
118
|
parser = @parse_context.new_parser(markup)
|
|
119
119
|
|
|
120
120
|
loop do
|
data/lib/liquid/tags/cycle.rb
CHANGED
data/lib/liquid/tags/for.rb
CHANGED
data/lib/liquid/tags/if.rb
CHANGED
data/lib/liquid/tags/include.rb
CHANGED
data/lib/liquid/tags/render.rb
CHANGED
|
@@ -85,10 +85,10 @@ module Liquid
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
# render (string) (with|for expression)? (as id)? (key: value)*
|
|
88
|
-
def
|
|
88
|
+
def strict2_parse(markup)
|
|
89
89
|
p = @parse_context.new_parser(markup)
|
|
90
90
|
|
|
91
|
-
@template_name_expr = parse_expression(
|
|
91
|
+
@template_name_expr = parse_expression(strict2_template_name(p), safe: true)
|
|
92
92
|
with_or_for = p.id?("for") || p.id?("with")
|
|
93
93
|
@variable_name_expr = safe_parse_expression(p) if with_or_for
|
|
94
94
|
@alias_name = p.consume(:id) if p.id?("as")
|
|
@@ -107,7 +107,7 @@ module Liquid
|
|
|
107
107
|
p.consume(:end_of_string)
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
def
|
|
110
|
+
def strict2_template_name(p)
|
|
111
111
|
p.consume(:string)
|
|
112
112
|
end
|
|
113
113
|
|
data/lib/liquid/template.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Liquid
|
|
|
25
25
|
# :lax acts like liquid 2.5 and silently ignores malformed tags in most cases.
|
|
26
26
|
# :warn is the default and will give deprecation warnings when invalid syntax is used.
|
|
27
27
|
# :strict enforces correct syntax for most tags
|
|
28
|
-
# :
|
|
28
|
+
# :strict2 enforces correct syntax for all tags
|
|
29
29
|
def error_mode=(mode)
|
|
30
30
|
Deprecations.warn("Template.error_mode=", "Environment#error_mode=")
|
|
31
31
|
Environment.default.error_mode = mode
|
data/lib/liquid/variable.rb
CHANGED
|
@@ -74,14 +74,14 @@ module Liquid
|
|
|
74
74
|
p.consume(:end_of_string)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def
|
|
77
|
+
def strict2_parse(markup)
|
|
78
78
|
@filters = []
|
|
79
79
|
p = @parse_context.new_parser(markup)
|
|
80
80
|
|
|
81
81
|
return if p.look(:end_of_string)
|
|
82
82
|
|
|
83
83
|
@name = parse_context.safe_parse_expression(p)
|
|
84
|
-
@filters <<
|
|
84
|
+
@filters << strict2_parse_filter_expressions(p) while p.consume?(:pipe)
|
|
85
85
|
p.consume(:end_of_string)
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -156,7 +156,7 @@ module Liquid
|
|
|
156
156
|
# argument = (positional_argument | keyword_argument)
|
|
157
157
|
# positional_argument = expression
|
|
158
158
|
# keyword_argument = id ":" expression
|
|
159
|
-
def
|
|
159
|
+
def strict2_parse_filter_expressions(p)
|
|
160
160
|
filtername = p.consume(:id)
|
|
161
161
|
filter_args = []
|
|
162
162
|
keyword_args = {}
|
data/lib/liquid/version.rb
CHANGED