在我的厨师erb模板中,我想获取模板被复制到的path。 所以它看起来像:
MY_PATH=<%= ###HOW DO I GET THE TEMPLATE PATH### %>
有没有办法得到这个?
使用variables的解决scheme:
file = '/etc/whatever/app.conf' template file do source 'app.conf.erb' variables( directory: ::File.dirname(file) ) action :create end
模板:
<%= @directory %>
其值将是: /etc/whatever
/etc/whatever