Skip to content

Instantly share code, notes, and snippets.

@db0sch
Last active May 11, 2024 09:01
Show Gist options
  • Save db0sch/57d2d8c8e3f478b183c68e8051fe3a01 to your computer and use it in GitHub Desktop.
Save db0sch/57d2d8c8e3f478b183c68e8051fe3a01 to your computer and use it in GitHub Desktop.
ERB Snippets (in VS Code with the Ruby extension)

Text Editor ERB Snippets and Bindings

Snippet Tab Trigger Output
ERB tags er <% %>
print ERB tags pe <%= %>
if block if <% if %>...<% end %>
if / else block ife <% if %>...<% else %>...<% end %>
else tag else <% else %>
elsif tag elsif <% elsif %>
unless block unless <% unless %>...<% end %>
end block end <% end %>
each helper each <% @things.each do ...
@db0sch
Copy link
Author

db0sch commented Nov 16, 2023

It was there. But for some reasons, my snippets are not working anymore on vscode, when I use Ruby LSP (by Shopify).
I have to investigate this when I have the time

@db0sch
Copy link
Author

db0sch commented Nov 16, 2023

Ok so in VSCode, if you have the Ruby LSP (by Shopify), it seems you have to install another extension to get the ERB snippets (e.g.pe + tab => <%= ... %>)
I picked this one: ERB-VSCode-snippets (as it seems to do just this). It does not have reviews though. Maybe a better one exist. If you have some suggestions, feel free to post here 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment