mirror of
https://github.com/kemko/liquid.git
synced 2026-01-04 17:25:41 +03:00
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.
18 lines
447 B
Ruby
18 lines
447 B
Ruby
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
|