Sha256: ec05e212ef45e72464a0dfcd7be387a370ad9899688559db00830d987a1db9ca

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 Bytes

Contents

# frozen_string_literal: true

module Liquid
  # 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 %}
  #
  class Echo < Tag
    attr_reader :variable

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

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

    class ParseTreeVisitor < Liquid::ParseTreeVisitor
      def children
        [@node.variable]
      end
    end
  end

  Template.register_tag('echo', Echo)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
liquid-5.3.0 lib/liquid/tags/echo.rb
liquid-5.2.0 lib/liquid/tags/echo.rb
liquid-5.1.0 lib/liquid/tags/echo.rb
liquid-5.0.1 lib/liquid/tags/echo.rb