mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 00:40:40 -07:00
- Fix forloop.first/last/size lookups to try hash key before method call - Fix tablerow cols parameter to use attributes['cols'] not @cols - Fix tablerow output format to match interpreter (newlines, row boundaries) - Fix capture compiler to access @body directly instead of iterating nodelist - Add CompiledTemplate class to encapsulate code and external_tags - Add external filter support via filter_handler - Add debug mode warnings for external tag/filter calls - Add Ruby 3.3 compatibility shim for peek_byte/scan_byte - Add comprehensive unit tests for output equivalence - Add benchmark comparing compiled vs interpreted rendering All 30 test templates now produce identical output between compiled Ruby and interpreted Liquid. Pre-compiled Ruby is 1.68x faster.
27 lines
528 B
Ruby
27 lines
528 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Compatibility shim for Ruby 3.3
|
|
# The Liquid library uses peek_byte and scan_byte which are only available in Ruby 3.4+
|
|
|
|
require 'strscan'
|
|
|
|
unless StringScanner.method_defined?(:peek_byte)
|
|
class StringScanner
|
|
def peek_byte
|
|
return nil if eos?
|
|
string.getbyte(pos)
|
|
end
|
|
end
|
|
end
|
|
|
|
unless StringScanner.method_defined?(:scan_byte)
|
|
class StringScanner
|
|
def scan_byte
|
|
return nil if eos?
|
|
byte = string.getbyte(pos)
|
|
self.pos += 1
|
|
byte
|
|
end
|
|
end
|
|
end
|