mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Compare commits
1 Commits
pz-strict-
...
default-bl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0da48495c |
@@ -4,11 +4,6 @@ module Liquid
|
||||
class Block < Tag
|
||||
MAX_DEPTH = 100
|
||||
|
||||
def initialize(tag_name, markup, options)
|
||||
super
|
||||
@blank = true
|
||||
end
|
||||
|
||||
def parse(tokens)
|
||||
@body = BlockBody.new
|
||||
while parse_body(@body, tokens)
|
||||
@@ -20,10 +15,6 @@ module Liquid
|
||||
@body.render(context)
|
||||
end
|
||||
|
||||
def blank?
|
||||
@blank
|
||||
end
|
||||
|
||||
def nodelist
|
||||
@body.nodelist
|
||||
end
|
||||
@@ -64,8 +55,6 @@ module Liquid
|
||||
parse_context.depth += 1
|
||||
begin
|
||||
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
|
||||
@blank &&= body.blank?
|
||||
|
||||
return false if end_tag_name == block_delimiter
|
||||
unless end_tag_name
|
||||
raise SyntaxError, parse_context.locale.t("errors.syntax.tag_never_closed", block_name: block_name)
|
||||
|
||||
@@ -21,11 +21,16 @@ module Liquid
|
||||
def parse(tokens)
|
||||
body = BlockBody.new
|
||||
body = @blocks.last.attachment while parse_body(body, tokens)
|
||||
if blank?
|
||||
@blank = @blocks.all? { |condition| condition.attachment.blank? }
|
||||
if @blank
|
||||
@blocks.each { |condition| condition.attachment.remove_blank_strings }
|
||||
end
|
||||
end
|
||||
|
||||
def blank?
|
||||
@blank
|
||||
end
|
||||
|
||||
def nodelist
|
||||
@blocks.map(&:attachment)
|
||||
end
|
||||
|
||||
@@ -62,12 +62,17 @@ module Liquid
|
||||
if parse_body(@for_block, tokens)
|
||||
parse_body(@else_block, tokens)
|
||||
end
|
||||
if blank?
|
||||
@blank = @for_block.blank? && (@else_block.nil? || @else_block.blank?)
|
||||
if @blank
|
||||
@for_block.remove_blank_strings
|
||||
@else_block&.remove_blank_strings
|
||||
end
|
||||
end
|
||||
|
||||
def blank?
|
||||
@blank
|
||||
end
|
||||
|
||||
def nodelist
|
||||
@else_block ? [@for_block, @else_block] : [@for_block]
|
||||
end
|
||||
|
||||
@@ -31,11 +31,16 @@ module Liquid
|
||||
def parse(tokens)
|
||||
while parse_body(@blocks.last.attachment, tokens)
|
||||
end
|
||||
if blank?
|
||||
@blank = @blocks.all? { |condition| condition.attachment.blank? }
|
||||
if @blank
|
||||
@blocks.each { |condition| condition.attachment.remove_blank_strings }
|
||||
end
|
||||
end
|
||||
|
||||
def blank?
|
||||
@blank
|
||||
end
|
||||
|
||||
def unknown_tag(tag, markup, tokens)
|
||||
if ['elsif', 'else'].include?(tag)
|
||||
push_block(tag, markup)
|
||||
|
||||
Reference in New Issue
Block a user