mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 10:20:43 -07:00
added interrupt class for continue/break statements
When a continue or break statement is executed it pushes an interrupt to a stack in context. If any non-handled interrupts are present blocks will cease to execute. The for loop can handle the most recent interrupt in the stack.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
module Liquid
|
||||
|
||||
# An interrupt is any command that breaks processing of a block (ex: a for loop).
|
||||
class Interrupt
|
||||
attr_reader :message
|
||||
|
||||
def initialize(message=nil)
|
||||
@message = message || "interrupt"
|
||||
end
|
||||
end
|
||||
|
||||
# Interrupt that is thrown whenever a {% break %} is called.
|
||||
class BreakInterrupt < Interrupt; end
|
||||
|
||||
# Interrupt that is thrown whenever a {% continue %} is called.
|
||||
class ContinueInterrupt < Interrupt; end
|
||||
end
|
||||
Reference in New Issue
Block a user