Class: Liquid::Tag
- Inherits:
-
Object
- Object
- Liquid::Tag
- Includes:
- ParserSwitching
- Defined in:
- lib/liquid/tag.rb,
lib/liquid/tag/disabler.rb,
lib/liquid/tag/disableable.rb
Direct Known Subclasses
Assign, Block, Break, Continue, Cycle, Decrement, Echo, Include, Increment, InlineComment, Render
Defined Under Namespace
Modules: Disableable, Disabler
Instance Attribute Summary collapse
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#nodelist ⇒ Object
readonly
Returns the value of attribute nodelist.
-
#parse_context ⇒ Object
(also: #options)
readonly
Returns the value of attribute parse_context.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Class Method Summary collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(tag_name, markup, parse_context) ⇒ Tag
constructor
A new instance of Tag.
- #name ⇒ Object
- #parse(_tokens) ⇒ Object
- #raw ⇒ Object
- #render(_context) ⇒ Object
-
#render_to_output_buffer(context, output) ⇒ Object
For backwards compatibility with custom tags.
Methods included from ParserSwitching
#parse_with_selected_parser, #strict_parse_with_error_mode_fallback
Constructor Details
#initialize(tag_name, markup, parse_context) ⇒ Tag
Returns a new instance of Tag.
34 35 36 37 38 39 |
# File 'lib/liquid/tag.rb', line 34 def initialize(tag_name, markup, parse_context) @tag_name = tag_name @markup = markup @parse_context = parse_context @line_number = parse_context.line_number end |
Instance Attribute Details
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
8 9 10 |
# File 'lib/liquid/tag.rb', line 8 def line_number @line_number end |
#nodelist ⇒ Object (readonly)
Returns the value of attribute nodelist.
8 9 10 |
# File 'lib/liquid/tag.rb', line 8 def nodelist @nodelist end |
#parse_context ⇒ Object (readonly) Also known as: options
Returns the value of attribute parse_context.
8 9 10 |
# File 'lib/liquid/tag.rb', line 8 def parse_context @parse_context end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
8 9 10 |
# File 'lib/liquid/tag.rb', line 8 def tag_name @tag_name end |
Class Method Details
.disable_tags(*tag_names) ⇒ Object
19 20 21 22 23 |
# File 'lib/liquid/tag.rb', line 19 def (*tag_names) tag_names += define_singleton_method(:disabled_tags) { tag_names } prepend(Disabler) end |
.parse(tag_name, markup, tokenizer, parse_context) ⇒ Object
13 14 15 16 17 |
# File 'lib/liquid/tag.rb', line 13 def parse(tag_name, markup, tokenizer, parse_context) tag = new(tag_name, markup, parse_context) tag.parse(tokenizer) tag end |
Instance Method Details
#blank? ⇒ Boolean
65 66 67 |
# File 'lib/liquid/tag.rb', line 65 def blank? false end |
#name ⇒ Object
48 49 50 |
# File 'lib/liquid/tag.rb', line 48 def name self.class.name.downcase end |
#parse(_tokens) ⇒ Object
41 42 |
# File 'lib/liquid/tag.rb', line 41 def parse(_tokens) end |
#raw ⇒ Object
44 45 46 |
# File 'lib/liquid/tag.rb', line 44 def raw "#{@tag_name} #{@markup}" end |
#render(_context) ⇒ Object
52 53 54 |
# File 'lib/liquid/tag.rb', line 52 def render(_context) '' end |
#render_to_output_buffer(context, output) ⇒ Object
For backwards compatibility with custom tags. In a future release, the semantics of the ‘render_to_output_buffer` method will become the default and the `render` method will be removed.
59 60 61 62 63 |
# File 'lib/liquid/tag.rb', line 59 def render_to_output_buffer(context, output) render_result = render(context) output << render_result if render_result output end |