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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 112da43191fdf32af9afb1ad6322ff2fab8b22b6d658073980ba236aa1834213
4
- data.tar.gz: b7ab5c91bc2f65b91a782027eedd8374f1f46629c791d6b2c07a8ba2c07d7314
3
+ metadata.gz: 88705bb2e645a541fb76afe0a59c727429aaae33824103fb94178b5edbbda54e
4
+ data.tar.gz: 5982801da2e3431575b2e32edfd0f46a3371b1c74060dc8936470df75c27c630
5
5
  SHA512:
6
- metadata.gz: c941dc92d57cf97c30a6db6eb206e7f00b780070b8dc790def3a8be06a3714562813b0ca8da34d5745be4432c839cf2f5946557d103ae0e56ffe5822b4ebf1e6
7
- data.tar.gz: 9491a34a69273c3cebe65208f935007e68dbd81a8b32913ebc7d0056863c9f3a30b6dff9d1da3b37af66e472aedf60c6979e22d5f500ba6d24bd4f8637449a3f
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 = :rigid # 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.
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`:
@@ -184,7 +184,7 @@ module Liquid
184
184
  end
185
185
 
186
186
  def key?(key)
187
- self[key] != nil
187
+ find_variable(key, raise_on_not_found: false) != nil
188
188
  end
189
189
 
190
190
  def evaluate(object)
@@ -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 :rigid, :strict, :warn, or :lax).
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.
@@ -55,15 +55,15 @@ module Liquid
55
55
  end
56
56
 
57
57
  def parse_expression(markup, safe: false)
58
- if !safe && @error_mode == :rigid
58
+ if !safe && @error_mode == :strict2
59
59
  # parse_expression is a widely used API. To maintain backward
60
- # compatibility while raising awareness about rigid parser standards,
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 rigid mode, markup MUST come from a string returned by the parser
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 rigid mode"
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 rigid mode where it uses the rigid parser.
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 rigid_parse_with_error_context(markup) if rigid_mode?
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 then rigid_parse_with_error_context(markup)
32
- when :strict then strict_parse_with_error_context(markup)
33
- when :lax then lax_parse(markup)
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
- rigid_parse_with_error_context(markup)
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 rigid_mode?
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 rigid_parse_with_error_context(markup)
51
- rigid_parse(markup)
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)
@@ -86,7 +86,7 @@ module Liquid
86
86
 
87
87
  private
88
88
 
89
- def rigid_parse(markup)
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 rigid_mode?
111
- parse_rigid_when(markup, body)
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 parse_rigid_when(markup, body)
117
+ def parse_strict2_when(markup, body)
118
118
  parser = @parse_context.new_parser(markup)
119
119
 
120
120
  loop do
@@ -56,7 +56,7 @@ module Liquid
56
56
  private
57
57
 
58
58
  # cycle [name:] expression(, expression)*
59
- def rigid_parse(markup)
59
+ def strict2_parse(markup)
60
60
  p = @parse_context.new_parser(markup)
61
61
 
62
62
  @variables = []
@@ -111,7 +111,7 @@ module Liquid
111
111
 
112
112
  private
113
113
 
114
- def rigid_parse(markup)
114
+ def strict2_parse(markup)
115
115
  strict_parse(markup)
116
116
  end
117
117
 
@@ -66,7 +66,7 @@ module Liquid
66
66
 
67
67
  private
68
68
 
69
- def rigid_parse(markup)
69
+ def strict2_parse(markup)
70
70
  strict_parse(markup)
71
71
  end
72
72
 
@@ -84,7 +84,7 @@ module Liquid
84
84
  alias_method :parse_context, :options
85
85
  private :parse_context
86
86
 
87
- def rigid_parse(markup)
87
+ def strict2_parse(markup)
88
88
  p = @parse_context.new_parser(markup)
89
89
 
90
90
  @template_name_expr = safe_parse_expression(p)
@@ -85,10 +85,10 @@ module Liquid
85
85
  end
86
86
 
87
87
  # render (string) (with|for expression)? (as id)? (key: value)*
88
- def rigid_parse(markup)
88
+ def strict2_parse(markup)
89
89
  p = @parse_context.new_parser(markup)
90
90
 
91
- @template_name_expr = parse_expression(rigid_template_name(p), safe: true)
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 rigid_template_name(p)
110
+ def strict2_template_name(p)
111
111
  p.consume(:string)
112
112
  end
113
113
 
@@ -34,7 +34,7 @@ module Liquid
34
34
  parse_with_selected_parser(markup)
35
35
  end
36
36
 
37
- def rigid_parse(markup)
37
+ def strict2_parse(markup)
38
38
  p = @parse_context.new_parser(markup)
39
39
 
40
40
  @variable_name = p.consume(:id)
@@ -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
- # :rigid enforces correct syntax for all tags
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
@@ -74,14 +74,14 @@ module Liquid
74
74
  p.consume(:end_of_string)
75
75
  end
76
76
 
77
- def rigid_parse(markup)
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 << rigid_parse_filter_expressions(p) while p.consume?(:pipe)
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 rigid_parse_filter_expressions(p)
159
+ def strict2_parse_filter_expressions(p)
160
160
  filtername = p.consume(:id)
161
161
  filter_args = []
162
162
  keyword_args = {}
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Liquid
5
- VERSION = "5.9.0"
5
+ VERSION = "5.11.0"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.9.0
4
+ version: 5.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Lütke