Class: Liquid2::TemplateString

Inherits:
Expression show all
Defined in:
lib/liquid2/expressions/template_string.rb

Overview

Quoted string with interpolated expressions.

Instance Attribute Summary

Attributes inherited from Expression

#token

Instance Method Summary collapse

Methods inherited from Expression

#scope

Constructor Details

#initialize(token, segments) ⇒ TemplateString

Returns a new instance of TemplateString.

Parameters:



9
10
11
12
# File 'lib/liquid2/expressions/template_string.rb', line 9

def initialize(token, segments)
  super(token)
  @segments = segments
end

Instance Method Details

#childrenObject



18
# File 'lib/liquid2/expressions/template_string.rb', line 18

def children = @segments

#evaluate(context) ⇒ Object



14
15
16
# File 'lib/liquid2/expressions/template_string.rb', line 14

def evaluate(context)
  @segments.map { |expr| Liquid2.to_s(context.evaluate(expr)) }.join
end