Sha256: 099c909d3de5afd48885e6b0f7bb6d9e58708bc0962d17a562f08e078ca869d8

Contents?: true

Size: 904 Bytes

Versions: 23

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module VagrantPlugins
  module ProviderLibvirt
    module Util
      module ErbTemplate
        # TODO: remove and use nokogiri builder
        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')
          template = "#{erb}.xml"

          # TODO: according to erubis documentation, we should rather use evaluate and forget about
          # binding since the template may then change variables values
          Vagrant::Util::TemplateRenderer.render_with(:render, template, template_root: path) do |renderer|
            iv = data.eval ("instance_variables.collect {|i| [i, instance_variable_get(i.to_sym)]}")
            iv.each {|k, v| renderer.instance_variable_set(k, v)}
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
vagrant-libvirt-0.12.2 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.12.1 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.12.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.11.2 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.11.1 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.8 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.7 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.6 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.5 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.4 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.3 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.2 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.1 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.10.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.9.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.8.2 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.8.1 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.8.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.7.0 lib/vagrant-libvirt/util/erb_template.rb
vagrant-libvirt-0.6.3 lib/vagrant-libvirt/util/erb_template.rb