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.
31 32 33 34 35 36 |
# File 'lib/liquid/tag.rb', line 31 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.
5 6 7 |
# File 'lib/liquid/tag.rb', line 5 def line_number @line_number end |
#nodelist ⇒ Object (readonly)
Returns the value of attribute nodelist.
5 6 7 |
# File 'lib/liquid/tag.rb', line 5 def nodelist @nodelist end |
#parse_context ⇒ Object (readonly) Also known as: options
Returns the value of attribute parse_context.
5 6 7 |
# File 'lib/liquid/tag.rb', line 5 def parse_context @parse_context end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
5 6 7 |
# File 'lib/liquid/tag.rb', line 5 def tag_name @tag_name end |
Class Method Details
.disable_tags(*tag_names) ⇒ Object
16 17 18 19 20 |
# File 'lib/liquid/tag.rb', line 16 def (*tag_names) tag_names += define_singleton_method(:disabled_tags) { tag_names } prepend(Disabler) end |
.parse(tag_name, markup, tokenizer, parse_context) ⇒ Object
10 11 12 13 14 |
# File 'lib/liquid/tag.rb', line 10 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
62 63 64 |
# File 'lib/liquid/tag.rb', line 62 def blank? false end |
#name ⇒ Object
45 46 47 |
# File 'lib/liquid/tag.rb', line 45 def name self.class.name.downcase end |
#parse(_tokens) ⇒ Object
38 39 |
# File 'lib/liquid/tag.rb', line 38 def parse(_tokens) end |
#raw ⇒ Object
41 42 43 |
# File 'lib/liquid/tag.rb', line 41 def raw "#{@tag_name} #{@markup}" end |
#render(_context) ⇒ Object
49 50 51 |
# File 'lib/liquid/tag.rb', line 49 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.
56 57 58 59 60 |
# File 'lib/liquid/tag.rb', line 56 def render_to_output_buffer(context, output) render_result = render(context) output << render_result if render_result output end |