I use erb with ruby -c to syntax check erb files.
How I do it:
cat layout.html.erb | erb -x -T '-' | ruby -c
For example this layout.html.erb file:
<div class="container">
<%= yield %>
</div>
Up until ruby 3.2 it always worked, meaning
# ruby 2.5, ruby 2.7.2, ruby 3.2
cat layout.html.erb | erb -x -T '-' | ruby -c
# => Syntax OK
But introducing ruby 3.3 we get an error:
# ruby 3.3
cat layout.html.erb | erb -x -T '-' | ruby -c
# => -:3: Invalid yield
# => ; _erbout.<<(( yield ).to_s); _erbout.<< "\n".fre...
# => -: compile error (SyntaxError)
For now I worked around it by removing the lines containing yield, using grep -v yield:
cat layout.html.erb | grep -v yield | erb -x -T '-' | ruby -c
Can you think of a different way of syntax checking a ruby 3.3 erb file containing yield?