mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-18 10:20:43 -07:00
Add else blocks to for and case nodelists
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
module Liquid
|
||||
class Tag
|
||||
attr_accessor :nodelist, :options
|
||||
attr_reader :warnings
|
||||
attr_accessor :options
|
||||
attr_reader :nodelist, :warnings
|
||||
|
||||
def self.new_with_options(tag_name, markup, tokens, options)
|
||||
# Forgive me Matz for I have sinned. I know this code is weird
|
||||
|
||||
@@ -15,6 +15,10 @@ module Liquid
|
||||
super
|
||||
end
|
||||
|
||||
def nodelist
|
||||
@blocks.map(&:attachment).flatten
|
||||
end
|
||||
|
||||
def unknown_tag(tag, markup, tokens)
|
||||
@nodelist = []
|
||||
case tag
|
||||
|
||||
@@ -52,6 +52,14 @@ module Liquid
|
||||
super
|
||||
end
|
||||
|
||||
def nodelist
|
||||
if @else_block
|
||||
@for_block + @else_block
|
||||
else
|
||||
@for_block
|
||||
end
|
||||
end
|
||||
|
||||
def unknown_tag(tag, markup, tokens)
|
||||
return super unless tag == 'else'
|
||||
@nodelist = @else_block = []
|
||||
|
||||
Reference in New Issue
Block a user