Skip to content

Commit

Permalink
Merge pull request #13 from lukewendling/master
Browse files Browse the repository at this point in the history
trim newlines in ERB closing tags
  • Loading branch information
dpickett committed Aug 26, 2014
2 parents 926d72c + b6e23be commit 8e44ff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/roboto/content_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def contents(custom_binding = nil)

@contents = File.read(path)
if path.extname == '.erb'
@contents = ERB.new(@contents).result(custom_binding ? custom_binding : binding)
@contents = ERB.new(@contents, nil, '>').result(custom_binding ? custom_binding : binding)
end
@contents
end
Expand Down
7 changes: 7 additions & 0 deletions spec/roboto/content_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
content_provider.contents.should eql(Rails.env)
end

it 'strips newlines in closing erb tags' do
path = Rails.root.join("config/robots/test.txt.erb")
File.open(path, 'wb') { |f| f.write("<% if true %>\n<%= Rails.env %>\n<% end %>") }
content_provider.path.should eql(path)
content_provider.contents.should eql(Rails.env)
end

it 'uses the default robots file if found in the rails root' do
path = Rails.root.join(relative_path_to_default)
FileUtils.touch(path)
Expand Down

0 comments on commit 8e44ff8

Please sign in to comment.