mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Remove warnings system
This commit is contained in:
+2
-1
@@ -22,11 +22,12 @@
|
|||||||
* e.g. `(a or b) and c`
|
* e.g. `(a or b) and c`
|
||||||
|
|
||||||
### Breaking changes
|
### Breaking changes
|
||||||
* We are removing the Environment's `error_mode` option.
|
* The Environment's `error_mode` option has been removed.
|
||||||
* `:warn` is no longer supported
|
* `:warn` is no longer supported
|
||||||
* `:lax` and `lax_parse` is no longer supported
|
* `:lax` and `lax_parse` is no longer supported
|
||||||
* `:strict` and `strict_parse` is no longer supported
|
* `:strict` and `strict_parse` is no longer supported
|
||||||
* `strict2_parse` is renamed to `parse_markup`
|
* `strict2_parse` is renamed to `parse_markup`
|
||||||
|
* The `warnings` system has been removed.
|
||||||
|
|
||||||
### Migrating from `^5.11.0`
|
### Migrating from `^5.11.0`
|
||||||
- In custom tags that include `ParserSwitching`, rename `strict2_parse` to `parse_markup`
|
- In custom tags that include `ParserSwitching`, rename `strict2_parse` to `parse_markup`
|
||||||
|
|||||||
@@ -60,10 +60,6 @@ module Liquid
|
|||||||
end
|
end
|
||||||
# rubocop:enable Metrics/ParameterLists
|
# rubocop:enable Metrics/ParameterLists
|
||||||
|
|
||||||
def warnings
|
|
||||||
@warnings ||= []
|
|
||||||
end
|
|
||||||
|
|
||||||
def strainer
|
def strainer
|
||||||
@strainer ||= @environment.create_strainer(self, @filters)
|
@strainer ||= @environment.create_strainer(self, @filters)
|
||||||
end
|
end
|
||||||
@@ -157,7 +153,6 @@ module Liquid
|
|||||||
subcontext.filters = @filters
|
subcontext.filters = @filters
|
||||||
subcontext.strainer = nil
|
subcontext.strainer = nil
|
||||||
subcontext.errors = errors
|
subcontext.errors = errors
|
||||||
subcontext.warnings = warnings
|
|
||||||
subcontext.disabled_tags = @disabled_tags
|
subcontext.disabled_tags = @disabled_tags
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -244,7 +239,7 @@ module Liquid
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
attr_writer :base_scope_depth, :warnings, :errors, :strainer, :filters, :disabled_tags
|
attr_writer :base_scope_depth, :errors, :strainer, :filters, :disabled_tags
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
module Liquid
|
module Liquid
|
||||||
class ParseContext
|
class ParseContext
|
||||||
attr_accessor :locale, :line_number, :trim_whitespace, :depth
|
attr_accessor :locale, :line_number, :trim_whitespace, :depth
|
||||||
attr_reader :partial, :warnings, :environment
|
attr_reader :partial, :environment
|
||||||
|
|
||||||
def initialize(options = Const::EMPTY_HASH)
|
def initialize(options = Const::EMPTY_HASH)
|
||||||
@environment = options.fetch(:environment, Environment.default)
|
@environment = options.fetch(:environment, Environment.default)
|
||||||
@template_options = options ? options.dup : {}
|
@template_options = options ? options.dup : {}
|
||||||
|
|
||||||
@locale = @template_options[:locale] ||= I18n.new
|
@locale = @template_options[:locale] ||= I18n.new
|
||||||
@warnings = []
|
|
||||||
|
|
||||||
# constructing new StringScanner in Lexer, Tokenizer, etc is expensive
|
# constructing new StringScanner in Lexer, Tokenizer, etc is expensive
|
||||||
# This StringScanner will be shared by all of them
|
# This StringScanner will be shared by all of them
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module Liquid
|
|||||||
#
|
#
|
||||||
class Template
|
class Template
|
||||||
attr_accessor :root, :name
|
attr_accessor :root, :name
|
||||||
attr_reader :resource_limits, :warnings
|
attr_reader :resource_limits
|
||||||
|
|
||||||
attr_reader :profiler
|
attr_reader :profiler
|
||||||
|
|
||||||
@@ -209,7 +209,6 @@ module Liquid
|
|||||||
ParseContext.new(opts)
|
ParseContext.new(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
@warnings = parse_context.warnings
|
|
||||||
parse_context
|
parse_context
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -44,16 +44,6 @@ class TemplateTest < Minitest::Test
|
|||||||
assert_equal('from instance assigns', t.parse("{{ foo }}").render!)
|
assert_equal('from instance assigns', t.parse("{{ foo }}").render!)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_warnings_is_not_exponential_time
|
|
||||||
str = "false"
|
|
||||||
100.times do
|
|
||||||
str = "{% if true %}true{% else %}#{str}{% endif %}"
|
|
||||||
end
|
|
||||||
|
|
||||||
t = Template.parse(str)
|
|
||||||
assert_equal([], Timeout.timeout(1) { t.warnings })
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_instance_assigns_persist_on_same_template_parsing_between_renders
|
def test_instance_assigns_persist_on_same_template_parsing_between_renders
|
||||||
t = Template.new.parse("{{ foo }}{% assign foo = 'foo' %}{{ foo }}")
|
t = Template.new.parse("{{ foo }}{% assign foo = 'foo' %}{{ foo }}")
|
||||||
assert_equal('foo', t.render!)
|
assert_equal('foo', t.render!)
|
||||||
|
|||||||
Reference in New Issue
Block a user