Compare commits

..
Author SHA1 Message Date
Ian Ker-Seymer 820b238288 Handle recursive array 2024-12-10 19:17:24 -05:00
Ian Ker-Seymer 5e459b884a Write one value at a time for array variables 2024-12-10 18:12:39 -05:00
15 changed files with 20 additions and 141 deletions
+1 -2
View File
@@ -13,8 +13,7 @@ jobs:
entry:
- { ruby: 3.0, allowed-failure: false } # minimum supported
- { ruby: 3.2, allowed-failure: false }
- { ruby: 3.3, allowed-failure: false }
- { ruby: "3.4.0-rc1", allowed-failure: false } # latest
- { ruby: 3.3, allowed-failure: false } # latest
- { ruby: ruby-head, allowed-failure: false }
name: Test Ruby ${{ matrix.entry.ruby }}
steps:
+1 -1
View File
@@ -1 +1 @@
3.3.6
3.3.4
+4
View File
@@ -23,4 +23,8 @@ group :test do
gem 'rubocop', '~> 1.61.0'
gem 'rubocop-shopify', '~> 2.12.0', require: false
gem 'rubocop-performance', require: false
platform :mri, :truffleruby do
gem 'liquid-c', github: 'Shopify/liquid-c', ref: 'main'
end
end
-10
View File
@@ -1,15 +1,5 @@
# Liquid Change Log
## 5.6.1 2025-01-07
Add `omit_blank_nodes` parse option to skip blank nodes in the AST (#1870) [Michael Go]
## 5.6.0 (unreleased)
### Fixes
* Fix Tokenizer to handle null source value (#1873) [Bahar Pourazar]
## 5.5.0 2024-03-21
Please reference the GitHub release for more information.
+2
View File
@@ -43,6 +43,8 @@ task :test do
Rake::Task['base_test'].invoke
if RUBY_ENGINE == 'ruby' || RUBY_ENGINE == 'truffleruby'
ENV['LIQUID_C'] = '1'
ENV['LIQUID_PARSER_MODE'] = 'lax'
Rake::Task['integration_test'].reenable
Rake::Task['integration_test'].invoke
-19
View File
@@ -58,9 +58,6 @@ module Liquid
return yield tag_name, markup
end
new_tag = tag.parse(tag_name, markup, tokenizer, parse_context)
next if parse_context.omit_blank_nodes && blank_node?(new_tag)
@blank &&= new_tag.blank?
@nodelist << new_tag
end
@@ -156,9 +153,6 @@ module Liquid
return yield tag_name, markup
end
new_tag = tag.parse(tag_name, markup, tokenizer, parse_context)
next if parse_context.omit_blank_nodes && blank_node?(new_tag)
@blank &&= new_tag.blank?
@nodelist << new_tag
when token.start_with?(VARSTART)
@@ -275,18 +269,5 @@ module Liquid
def raise_missing_variable_terminator(token, parse_context)
BlockBody.raise_missing_variable_terminator(token, parse_context)
end
def blank_node?(node)
case node
when Comment
true
when BlockBody
true if node.nodelist.empty?
when Tag
node.nodelist.all? { |n| blank_node?(n) }
else
false
end
end
end
end
+1 -5
View File
@@ -3,7 +3,7 @@
module Liquid
class ParseContext
attr_accessor :locale, :line_number, :trim_whitespace, :depth
attr_reader :partial, :warnings, :error_mode, :environment, :omit_blank_nodes
attr_reader :partial, :warnings, :error_mode, :environment
def initialize(options = Const::EMPTY_HASH)
@environment = options.fetch(:environment, Environment.default)
@@ -12,10 +12,6 @@ module Liquid
@locale = @template_options[:locale] ||= I18n.new
@warnings = []
# remove blank nodes such as
# comment tags, empty if tags, etc from the AST
@omit_blank_nodes = options.fetch(:omit_blank_nodes, false)
self.depth = 0
self.partial = false
end
+1 -1
View File
@@ -5,7 +5,7 @@ module Liquid
attr_reader :line_number, :for_liquid_tag
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
@source = source.to_s.to_str
@source = source
@line_number = line_number || (line_numbers ? 1 : nil)
@for_liquid_tag = for_liquid_tag
@offset = 0
+1 -1
View File
@@ -2,5 +2,5 @@
# frozen_string_literal: true
module Liquid
VERSION = "5.6.1"
VERSION = "5.6.0.rc1"
end
+1 -1
View File
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.summary = "A secure, non-evaling end user template engine with aesthetic markup."
s.authors = ["Tobias Lütke"]
s.email = ["[email protected]"]
s.homepage = "https://shopify.github.io/liquid/"
s.homepage = "http://www.liquidmarkup.org"
s.license = "MIT"
# s.description = "A secure, non-evaling end user template engine with aesthetic markup."
+1
View File
@@ -1,3 +1,4 @@
<div id="page" class="innerpage clearfix">
<div id="text-page">
<div class="entry">
+5
View File
@@ -15,6 +15,11 @@ if (env_mode = ENV['LIQUID_PARSER_MODE'])
end
Liquid::Environment.default.error_mode = mode
if ENV['LIQUID_C'] == '1'
puts "-- LIQUID C"
require 'liquid/c'
end
if Minitest.const_defined?('Test')
# We're on Minitest 5+. Nothing to do here.
else
-95
View File
@@ -53,103 +53,8 @@ class BlockUnitTest < Minitest::Test
assert_equal(3, template.root.nodelist.size)
end
def test_remove_empty_for_blocks_with_optimization_option
source = <<~LIQUID.chomp
{% for i in (1..1000000) %}
{% endfor %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% for i in (1..1000000) %}
{% else %}
{% endfor %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% for i in list %}
i
{% endfor %}
LIQUID
assert_root_nodelist_size(source, 1, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% for i in list %}
{% else %}
1
{% endfor %}
LIQUID
assert_root_nodelist_size(source, 1, omit_blank_nodes: true)
end
def test_remove_comment_nodes_with_optimization_option
source = <<~LIQUID.chomp
{% comment %}
{% if true %}
{% endif %}
{% endcomment %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% liquid
comment
if true
endif
endcomment
%}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
end
def test_remove_if_nodes_with_optimization_option
source = <<~LIQUID.chomp
{% if true %}
{% endif %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% unless true %}
{% endunless %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% if false %}
{% else %}
{% endif %}
LIQUID
assert_root_nodelist_size(source, 0, omit_blank_nodes: true)
source = <<~LIQUID.chomp
{% if false %}
{% else %}
Hello!
{% endif %}
LIQUID
assert_root_nodelist_size(source, 1, omit_blank_nodes: true)
end
private
def assert_root_nodelist_size(source, expected_size, parse_options = {})
template = Liquid::Template.parse(source, parse_options)
assert_equal(expected_size, template.root.nodelist.size)
end
def block_types(nodelist)
nodelist.collect(&:class)
end
+2 -2
View File
@@ -7,13 +7,13 @@ class TemplateUnitTest < Minitest::Test
def test_sets_default_localization_in_document
t = Template.new
t.parse('{%raw%}{%endraw%}')
t.parse('{%comment%}{%endcomment%}')
assert_instance_of(I18n, t.root.nodelist[0].options[:locale])
end
def test_sets_default_localization_in_context_with_quick_initialization
t = Template.new
t.parse('{%raw%}{%endraw%}', locale: I18n.new(fixture("en_locale.yml")))
t.parse('{%comment%}{%endcomment%}', locale: I18n.new(fixture("en_locale.yml")))
locale = t.root.nodelist[0].options[:locale]
assert_instance_of(I18n, locale)
-4
View File
@@ -30,10 +30,6 @@ class TokenizerTest < Minitest::Test
assert_equal([1, 1, 3], tokenize_line_numbers(" {{\n funk \n}} "))
end
def test_tokenize_with_nil_source_returns_empty_array
assert_equal([], tokenize(nil))
end
private
def new_tokenizer(source, parse_context: Liquid::ParseContext.new, start_line_number: nil)