Sha256: bc3758485797d86c42119bde4077e83192ca18c433458f5619353a9a1998746b

Contents?: true

Size: 840 Bytes

Versions: 8

Compression:

Stored size: 840 Bytes

Contents

require 'erubis'

module VagrantPlugins
  module ProviderLibvirt
    module Util
      module ErbTemplate
        # TODO: remove and use nokogiri builder
        # 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

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-libvirt-0.1.2 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.1.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.45 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.43 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.42 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.40 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.39 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.0.38 lib/vagrant-libvirt/util/erb_template.rb