From 3371c3716278071680af9b526ba19235c79c64cb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 2 Apr 2014 09:53:20 -0700 Subject: [PATCH] TemplateRenderer can take a new root [GH-3231] --- lib/vagrant/util/template_renderer.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/template_renderer.rb b/lib/vagrant/util/template_renderer.rb index 414e26621..dcdd892f0 100644 --- a/lib/vagrant/util/template_renderer.rb +++ b/lib/vagrant/util/template_renderer.rb @@ -1,4 +1,6 @@ require 'ostruct' +require "pathname" + require 'erubis' module Vagrant @@ -38,6 +40,10 @@ module Vagrant def initialize(template, data = {}) super() + @template_root = data.delete(:template_root) + @template_root ||= Vagrant.source_root.join("templates") + @template_root = Pathname.new(@template_root) + data[:template] = template data.each do |key, value| send("#{key}=", value) @@ -76,7 +82,7 @@ module Vagrant # # @return [String] def full_template_path - Vagrant.source_root.join('templates', "#{template}.erb").to_s.squeeze("/") + @template_root.join("#{template}.erb").to_s.squeeze("/") end end end