diff --git a/bin/rake b/bin/rake
new file mode 100755
index 0000000..4eb7d7b
--- /dev/null
+++ b/bin/rake
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'rake' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
+
+bundle_binstub = File.expand_path("bundle", __dir__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("rake", "rake")
diff --git a/lib/erb/formatter.rb b/lib/erb/formatter.rb
index b14b375..3e1db4f 100644
--- a/lib/erb/formatter.rb
+++ b/lib/erb/formatter.rb
@@ -61,6 +61,7 @@ class Error < StandardError; end
end.freeze
end
+ RUBY_STANDALONE_BLOCK = /\A(yield|next)\b/
RUBY_CLOSE_BLOCK = /\Aend\z/
RUBY_REOPEN_BLOCK = /\A(else|elsif\b(.*)|when\b(.*))\z/
@@ -306,6 +307,10 @@ def format_erb_tags(string)
erb_open << ' ' unless ruby_code.start_with?('#')
case ruby_code
+ when RUBY_STANDALONE_BLOCK
+ ruby_code = format_ruby(ruby_code, autoclose: false)
+ full_erb_tag = "#{erb_open}#{ruby_code} #{erb_close}"
+ html << (erb_pre_match.match?(/\s+\z/) ? indented(full_erb_tag) : full_erb_tag)
when RUBY_CLOSE_BLOCK
full_erb_tag = "#{erb_open}#{ruby_code} #{erb_close}"
tag_stack_pop('%erb%', ruby_code)
diff --git a/test/fixtures/yield.html.erb b/test/fixtures/yield.html.erb
new file mode 100644
index 0000000..5dc9a73
--- /dev/null
+++ b/test/fixtures/yield.html.erb
@@ -0,0 +1,24 @@
+