class Mixml::Template::Text

Ruby string template

Attributes

text[R]

@return [String] Template text

Public Class Methods

new(text) click to toggle source

Initialize a new template

@param text [String] Template text

# File lib/mixml/template/text.rb, line 13
def initialize(text)
    raise(ArgumentError, 'Text must not be nil.') if text.nil?

    @text = '"' << text.gsub('"', '\"') << '"'
end

Public Instance Methods

evaluate(node) click to toggle source

Evaulate the template using Ruby string interpolation

@param node [Nokogiri::XML::Node] Current node

# File lib/mixml/template/text.rb, line 22
def evaluate(node)
    eval(@text, binding)
end