Class: Liquid::Document

Inherits:
BlockBody show all
Defined in:
lib/liquid/document.rb

Constant Summary

Constants inherited from BlockBody

BlockBody::ContentOfVariable, BlockBody::FullToken, BlockBody::TAGSTART, BlockBody::VARSTART

Instance Attribute Summary

Attributes inherited from BlockBody

#nodelist

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BlockBody

#blank?, #initialize, #render, #render_node_with_profiling, #whitespace_handler

Constructor Details

This class inherits a constructor from Liquid::BlockBody

Class Method Details

.parse(tokens, parse_context) ⇒ Object


3
4
5
6
7
# File 'lib/liquid/document.rb', line 3

def self.parse(tokens, parse_context)
  doc = new
  doc.parse(tokens, parse_context)
  doc
end

Instance Method Details

#parse(tokens, parse_context) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/liquid/document.rb', line 9

def parse(tokens, parse_context)
  super do |end_tag_name, end_tag_params|
    unknown_tag(end_tag_name, parse_context) if end_tag_name
  end
rescue SyntaxError => e
  e.line_number ||= parse_context.line_number
  raise
end

#unknown_tag(tag, parse_context) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/liquid/document.rb', line 18

def unknown_tag(tag, parse_context)
  case tag
  when 'else'.freeze, 'end'.freeze
    raise SyntaxError.new(parse_context.locale.t("errors.syntax.unexpected_outer_tag".freeze, tag: tag))
  else
    raise SyntaxError.new(parse_context.locale.t("errors.syntax.unknown_tag".freeze, tag: tag))
  end
end