class Liquid::Block
Public Class Methods
new(tag_name, markup, options)
click to toggle source
Calls superclass method
# File lib/liquid/block.rb, line 3 def initialize(tag_name, markup, options) super @blank = true end
Public Instance Methods
blank?()
click to toggle source
# File lib/liquid/block.rb, line 18 def blank? @blank end
block_delimiter()
click to toggle source
# File lib/liquid/block.rb, line 44 def block_delimiter @block_delimiter ||= "end#{block_name}" end
block_name()
click to toggle source
# File lib/liquid/block.rb, line 40 def block_name @tag_name end
nodelist()
click to toggle source
# File lib/liquid/block.rb, line 22 def nodelist @body.nodelist end
parse(tokens)
click to toggle source
# File lib/liquid/block.rb, line 8 def parse(tokens) @body = BlockBody.new while parse_body(@body, tokens) end end
render(context)
click to toggle source
# File lib/liquid/block.rb, line 14 def render(context) @body.render(context) end
unknown_tag(tag, _params, _tokens)
click to toggle source
# File lib/liquid/block.rb, line 26 def unknown_tag(tag, _params, _tokens) case tag when 'else'.freeze raise SyntaxError.new(parse_context.locale.t("errors.syntax.unexpected_else".freeze, block_name: block_name)) when 'end'.freeze raise SyntaxError.new(parse_context.locale.t("errors.syntax.invalid_delimiter".freeze, block_name: block_name, block_delimiter: block_delimiter)) else raise SyntaxError.new(parse_context.locale.t("errors.syntax.unknown_tag".freeze, tag: tag)) end end
Protected Instance Methods
parse_body(body, tokens)
click to toggle source
# File lib/liquid/block.rb, line 50 def parse_body(body, tokens) 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.new(parse_context.locale.t("errors.syntax.tag_never_closed".freeze, block_name: block_name)) end # this tag is not registered with the system # pass it to the current block for special handling or error reporting unknown_tag(end_tag_name, end_tag_params, tokens) end true end