TemplateRenderer can take a new root [GH-3231]
This commit is contained in:
parent
a1d9121852
commit
3371c37162
|
@ -1,4 +1,6 @@
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
require "pathname"
|
||||||
|
|
||||||
require 'erubis'
|
require 'erubis'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
|
@ -38,6 +40,10 @@ module Vagrant
|
||||||
def initialize(template, data = {})
|
def initialize(template, data = {})
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@template_root = data.delete(:template_root)
|
||||||
|
@template_root ||= Vagrant.source_root.join("templates")
|
||||||
|
@template_root = Pathname.new(@template_root)
|
||||||
|
|
||||||
data[:template] = template
|
data[:template] = template
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
send("#{key}=", value)
|
send("#{key}=", value)
|
||||||
|
@ -76,7 +82,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def full_template_path
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue