Skip to content

Commit 32b50ec

Browse files
authored
Bump Liquid to 5.11.0 (#2012)
This commit reverts the Inline Snippets tag (#2001) and bumps Liquid to 5.11. For now, the inclusion of Inline Snippets in the latest Liquid release is being treated as a bug. While #2001 does implement the scope contained in RFC#1916, we need to take a step back to make sure we’re setting our sights high enough with this feature, and that we’re truly supporting theme developers in the ways they need. If you have any feedback, please leave a comment on RFC#1916. - Liquid Developer Tools
1 parent cbd8a0a commit 32b50ec

33 files changed

+164
-1327
lines changed

History.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# Liquid Change Log
22

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+
37
## 5.10.0
48
* Introduce support for Inline Snippets [Julia Boutin]
5-
```
6-
{%- snippet snowdevil -%}
7-
Snowdevil
8-
{%- endsnippet -%}
9-
{% render snowdevil %}
10-
```
119

1210
## 5.9.0
1311
* Introduce `:rigid` error mode for stricter, safer parsing of all tags [CP Clermont, Guilherme Carreiro]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ Liquid also comes with different parsers that can be used when editing templates
103103
when templates are invalid. You can enable this new parser like this:
104104

105105
```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.
110110
```
111111

112112
If you want to set the error mode only on specific templates you can pass `:error_mode` as an option to `parse`:

Rakefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ task :rubocop do
3333
end
3434
end
3535

36-
desc('runs test suite with lax, strict, and rigid parsers')
36+
desc('runs test suite with lax, strict, and strict2 parsers')
3737
task :test do
3838
ENV['LIQUID_PARSER_MODE'] = 'lax'
3939
Rake::Task['base_test'].invoke
@@ -42,7 +42,7 @@ task :test do
4242
Rake::Task['base_test'].reenable
4343
Rake::Task['base_test'].invoke
4444

45-
ENV['LIQUID_PARSER_MODE'] = 'rigid'
45+
ENV['LIQUID_PARSER_MODE'] = 'strict2'
4646
Rake::Task['base_test'].reenable
4747
Rake::Task['base_test'].invoke
4848

@@ -55,7 +55,7 @@ task :test do
5555
Rake::Task['integration_test'].reenable
5656
Rake::Task['integration_test'].invoke
5757

58-
ENV['LIQUID_PARSER_MODE'] = 'rigid'
58+
ENV['LIQUID_PARSER_MODE'] = 'strict2'
5959
Rake::Task['integration_test'].reenable
6060
Rake::Task['integration_test'].invoke
6161
end
@@ -88,13 +88,13 @@ namespace :benchmark do
8888
ruby "./performance/benchmark.rb strict"
8989
end
9090

91-
desc "Run the liquid benchmark with rigid parsing"
92-
task :rigid do
93-
ruby "./performance/benchmark.rb rigid"
91+
desc "Run the liquid benchmark with strict2 parsing"
92+
task :strict2 do
93+
ruby "./performance/benchmark.rb strict2"
9494
end
9595

96-
desc "Run the liquid benchmark with lax, strict, and rigid parsing"
97-
task run: [:lax, :strict, :rigid]
96+
desc "Run the liquid benchmark with lax, strict, and strict2 parsing"
97+
task run: [:lax, :strict, :strict2]
9898

9999
desc "Run unit benchmarks"
100100
namespace :unit do

bin/render

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ def assigns
4141
end
4242

4343
puts Liquid::Template
44-
.parse(source, error_mode: :rigid)
44+
.parse(source, error_mode: :strict2)
4545
.tap { |t| t.registers[:file_system] = VirtualFileSystem.new }
4646
.render(assigns)

lib/liquid.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ module Liquid
6767
require 'liquid/drop'
6868
require 'liquid/tablerowloop_drop'
6969
require 'liquid/forloop_drop'
70-
require 'liquid/snippet_drop'
7170
require 'liquid/extensions'
7271
require 'liquid/errors'
7372
require 'liquid/interrupts'

lib/liquid/environment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class << self
3434
# @param file_system The default file system that is used
3535
# to load templates from.
3636
# @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).
3838
# @param exception_renderer [Proc] The exception renderer that is used to
3939
# render exceptions.
4040
# @yieldparam environment [Environment] The environment instance that is being built.

lib/liquid/locales/en.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
block_tag_unexpected_args: "Syntax Error in '%{tag}' - Valid syntax: {% %{tag} %}{% end%{tag} %}"
66
assign: "Syntax Error in 'assign' - Valid syntax: assign [var] = [source]"
77
capture: "Syntax Error in 'capture' - Valid syntax: capture [var]"
8-
snippet: "Syntax Error in 'snippet' - Valid syntax: snippet [var]"
98
case: "Syntax Error in 'case' - Valid syntax: case [condition]"
109
case_invalid_when: "Syntax Error in tag 'case' - Valid when condition: {% when [condition] [or condition2...] %}"
1110
case_invalid_else: "Syntax Error in tag 'case' - Valid else condition: {% else %} (no parameters) "
@@ -20,7 +19,6 @@
2019
invalid_delimiter: "'%{tag}' is not a valid delimiter for %{block_name} tags. use %{block_delimiter}"
2120
invalid_template_encoding: "Invalid template encoding"
2221
render: "Syntax error in tag 'render' - Template name must be a quoted string"
23-
render_invalid_template_name: "Syntax error in tag 'render' - Expected a string or identifier, found %{found}"
2422
table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3"
2523
table_row_invalid_attribute: "Invalid attribute '%{attribute}' in tablerow loop. Valid attributes are cols, limit, offset, and range"
2624
tag_never_closed: "'%{block_name}' tag was never closed"
@@ -31,6 +29,5 @@
3129
variable_termination: "Variable '%{token}' was not properly terminated with regexp: %{tag_end}"
3230
argument:
3331
include: "Argument error in tag 'include' - Illegal template name"
34-
render: "Argument error in tag 'render' - Dynamically chosen templates are not allowed"
3532
disabled:
3633
tag: "usage is not allowed in this context"

lib/liquid/parse_context.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ def safe_parse_expression(parser)
5555
end
5656

5757
def parse_expression(markup, safe: false)
58-
if !safe && @error_mode == :rigid
58+
if !safe && @error_mode == :strict2
5959
# 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,
6161
# the safe flag supports API users make a deliberate decision.
6262
#
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
6464
# (e.g., parser.expression). We're not calling the parser here to
6565
# 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"
6767
end
6868

6969
Expression.parse(markup, @string_scanner, @expression_cache)

lib/liquid/parser_switching.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ module ParserSwitching
77
# It's basically doing the same thing the {#parse_with_selected_parser},
88
# except this will try the strict parser regardless of the error mode,
99
# 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.
1111
#
1212
# @deprecated Use {#parse_with_selected_parser} instead.
1313
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?
1515

1616
strict_parse_with_error_context(markup)
1717
rescue SyntaxError => e
1818
case parse_context.error_mode
1919
when :rigid
20+
rigid_warn
21+
raise
22+
when :strict2
2023
raise
2124
when :strict
2225
raise
@@ -28,27 +31,32 @@ def strict_parse_with_error_mode_fallback(markup)
2831

2932
def parse_with_selected_parser(markup)
3033
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)
3438
when :warn
3539
begin
36-
rigid_parse_with_error_context(markup)
40+
strict2_parse_with_error_context(markup)
3741
rescue SyntaxError => e
3842
parse_context.warnings << e
3943
lax_parse(markup)
4044
end
4145
end
4246
end
4347

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
4650
end
4751

4852
private
4953

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)
5260
rescue SyntaxError => e
5361
e.line_number = line_number
5462
e.markup_context = markup_context(markup)

lib/liquid/snippet_drop.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)