class Burner::Util::StringTemplate

Can take in a string and an object and use the object for formatting string interpolations using tokens of form: {attribute_name}. This templating class does not understand nested structures, so input should be a flat object/hash in the form of key-value pairs. A benefit of using Objectable for resolution is that it can understand almost any type of object: Hash, Struct, OpenStruct, custom objects, etc. For more information see underlying libraries:

* Stringento: https://github.com/bluemarblepayroll/stringento
* Objectable: https://github.com/bluemarblepayroll/objectable

Attributes

resolver[R]

Public Class Methods

new() click to toggle source
# File lib/burner/util/string_template.rb, line 25
def initialize
  @resolver = Objectable.resolver(separator: '')

  freeze
end

Public Instance Methods

evaluate(expression, input) click to toggle source

For general consumption

# File lib/burner/util/string_template.rb, line 32
def evaluate(expression, input)
  Stringento.evaluate(expression, input, resolver: self)
end
resolve(value, input) click to toggle source

For Stringento consumption

# File lib/burner/util/string_template.rb, line 37
def resolve(value, input)
  resolver.get(input, value)
end