mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
[StaticRegisters] Fetch raise on missing
Co-authored-by: Dylan Thacker-Smith <[email protected]>
This commit is contained in:
co-authored by
Dylan Thacker-Smith
parent
bd0e53bd2e
commit
b9979088ec
@@ -25,8 +25,16 @@ module Liquid
|
||||
@registers.delete(key)
|
||||
end
|
||||
|
||||
def fetch(key, default = nil)
|
||||
key?(key) ? self[key] : default
|
||||
UNDEFINED = Object.new
|
||||
|
||||
def fetch(key, default = UNDEFINED, &block)
|
||||
if @registers.key?(key)
|
||||
@registers.fetch(key)
|
||||
elsif default != UNDEFINED
|
||||
@static.fetch(key, default, &block)
|
||||
else
|
||||
@static.fetch(key, &block)
|
||||
end
|
||||
end
|
||||
|
||||
def key?(key)
|
||||
|
||||
Reference in New Issue
Block a user