Sha256: 120a21ccf60a2410417677f54f202b74415dc3f83d5000ae4caded5cea917541

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

require 'erubis'

module VagrantPlugins
  module ProviderLibvirt
    module Util
      module ErbTemplate
        # TODO: might be a chance to use vagrant template system according to https://github.com/mitchellh/vagrant/issues/3231
        def to_xml(template_name = nil, data = binding)
          erb = template_name || self.class.to_s.split('::').last.downcase
          path = File.join(File.dirname(__FILE__), '..', 'templates',
                           "#{erb}.xml.erb")
          template = File.read(path)

          # TODO: according to erubis documentation, we should rather use evaluate and forget about
          # binding since the template may then change variables values
          Erubis::Eruby.new(template, trim: true).result(data)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-libvirt-0.0.37 lib/vagrant-libvirt/util/erb_template.rb