From b6719d00d9013c0d1d8b888e4ac1dd46b386fd32 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 1 Aug 2010 17:26:37 -0700 Subject: [PATCH] Enable ability to supress newlines in ERB for templates using -%> --- lib/vagrant/util/template_renderer.rb | 2 +- templates/Vagrantfile.erb | 7 ++++--- templates/strings.yml | 2 +- test/vagrant/util/template_renderer_test.rb | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/vagrant/util/template_renderer.rb b/lib/vagrant/util/template_renderer.rb index 243581a4f..a1ab0208f 100644 --- a/lib/vagrant/util/template_renderer.rb +++ b/lib/vagrant/util/template_renderer.rb @@ -68,7 +68,7 @@ module Vagrant # # @return [String] def render_string - ERB.new(template).result(binding) + ERB.new(template, nil, "%<>-").result(binding) end # Returns the full path to the template, taking into accoun the gem directory diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index 68c1e3f12..5c03b00b4 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -6,8 +6,9 @@ Vagrant::Config.run do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "<%= default_box %>" - <% if !default_box_url.nil? %> - # The url from where the 'config.vm.box' box will be fetched + <% if !default_box_url.nil? -%> + # The url from where the 'config.vm.box' box will be fetched if it + # doesn't already exist on the user's system config.vm.box_url = "<%= default_box_url %>" - <% end %> + <% end -%> end diff --git a/templates/strings.yml b/templates/strings.yml index c21799047..d4deab908 100644 --- a/templates/strings.yml +++ b/templates/strings.yml @@ -191,7 +191,7 @@ Unknown provisioner type: <%= provisioner %> :rootfile_already_exists: |- It looks like this directory is already setup for vagrant! (A <%= Vagrant::Environment::ROOTFILE_NAME %> - already exists.) + already exists.) :rootfile_not_found: |- A `<%= Vagrant::Environment::ROOTFILE_NAME %>` was not found! This file is required for vagrant to run since it describes the expected environment that vagrant is supposed diff --git a/test/vagrant/util/template_renderer_test.rb b/test/vagrant/util/template_renderer_test.rb index dbca3a339..60607277d 100644 --- a/test/vagrant/util/template_renderer_test.rb +++ b/test/vagrant/util/template_renderer_test.rb @@ -60,7 +60,7 @@ class TemplateRendererUtilTest < Test::Unit::TestCase end should "simply render the template as a string" do - ERB.expects(:new).with(@r.template).returns(@erb) + ERB.expects(:new).with(@r.template, nil, "%<>-").returns(@erb) assert_equal @result, @r.render_string end end