Module: VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
- Included in:
- Action::CreateDomain, Action::CreateDomainVolume, Action::CreateNetworkInterfaces, Action::CreateNetworks, Action::HandleStoragePool, SyncedFolder9P::SyncedFolder, SyncedFolderVirtioFS::SyncedFolder
- Defined in:
- lib/vagrant-libvirt/util/erb_template.rb
Instance Method Summary collapse
-
#to_xml(template_name = nil, data = binding) ⇒ Object
TODO: remove and use nokogiri builder.
Instance Method Details
#to_xml(template_name = nil, data = binding) ⇒ Object
TODO: remove and use nokogiri builder
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/vagrant-libvirt/util/erb_template.rb', line 8 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 |