Class: Liquid::Echo

Inherits:
Tag
  • Object
show all
Defined in:
lib/liquid/tags/echo.rb

Overview

Echo outputs an expression

{% echo monkey %}
{% echo user.name %}

This is identical to variable output syntax, like foo }, but works inside liquid % tags. The full syntax is supported, including filters:

{% echo user | link %}

Defined Under Namespace

Classes: ParseTreeVisitor

Instance Attribute Summary collapse

Attributes inherited from Tag

#line_number, #nodelist, #parse_context, #tag_name

Instance Method Summary collapse

Methods inherited from Tag

#blank?, disable_tags, #name, parse, #parse, #raw, #render_to_output_buffer

Methods included from ParserSwitching

#parse_with_selected_parser, #strict_parse_with_error_mode_fallback

Constructor Details

#initialize(tag_name, markup, parse_context) ⇒ Echo

Returns a new instance of Echo.



17
18
19
20
# File 'lib/liquid/tags/echo.rb', line 17

def initialize(tag_name, markup, parse_context)
  super
  @variable = Variable.new(markup, parse_context)
end

Instance Attribute Details

#variableObject (readonly)

Returns the value of attribute variable.



15
16
17
# File 'lib/liquid/tags/echo.rb', line 15

def variable
  @variable
end

Instance Method Details

#render(context) ⇒ Object



22
23
24
# File 'lib/liquid/tags/echo.rb', line 22

def render(context)
  @variable.render_to_output_buffer(context, +'')
end