Class: Liquid::Document
- Inherits:
-
Object
- Object
- Liquid::Document
- Includes:
- DocumentProfilingHook
- Defined in:
- lib/liquid/document.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#parse_context ⇒ Object
readonly
Returns the value of attribute parse_context.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parse_context) ⇒ Document
constructor
A new instance of Document.
- #nodelist ⇒ Object
- #parse(tokenizer, parse_context) ⇒ Object
- #render(context) ⇒ Object
- #render_to_output_buffer(context, output) ⇒ Object
- #unknown_tag(tag, _markup, _tokenizer) ⇒ Object
Constructor Details
#initialize(parse_context) ⇒ Document
Returns a new instance of Document.
13 14 15 16 |
# File 'lib/liquid/document.rb', line 13 def initialize(parse_context) @parse_context = parse_context @body = new_body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/liquid/document.rb', line 11 def body @body end |
#parse_context ⇒ Object (readonly)
Returns the value of attribute parse_context.
11 12 13 |
# File 'lib/liquid/document.rb', line 11 def parse_context @parse_context end |
Class Method Details
.parse(tokens, parse_context) ⇒ Object
5 6 7 8 9 |
# File 'lib/liquid/document.rb', line 5 def self.parse(tokens, parse_context) doc = new(parse_context) doc.parse(tokens, parse_context) doc end |
Instance Method Details
#nodelist ⇒ Object
18 19 20 |
# File 'lib/liquid/document.rb', line 18 def nodelist @body.nodelist end |
#parse(tokenizer, parse_context) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/liquid/document.rb', line 22 def parse(tokenizer, parse_context) while parse_body(tokenizer) end @body.freeze rescue SyntaxError => e e.line_number ||= parse_context.line_number raise end |
#render(context) ⇒ Object
44 45 46 |
# File 'lib/liquid/document.rb', line 44 def render(context) render_to_output_buffer(context, +'') end |
#render_to_output_buffer(context, output) ⇒ Object
40 41 42 |
# File 'lib/liquid/document.rb', line 40 def render_to_output_buffer(context, output) @body.render_to_output_buffer(context, output) end |
#unknown_tag(tag, _markup, _tokenizer) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/liquid/document.rb', line 31 def unknown_tag(tag, _markup, _tokenizer) case tag when 'else', 'end' raise SyntaxError, parse_context.locale.t("errors.syntax.unexpected_outer_tag", tag: tag) else raise SyntaxError, parse_context.locale.t("errors.syntax.unknown_tag", tag: tag) end end |