This extension is a fork of ERB-VSCode-Snippets which is a fork of ERB-Sublime-Snippets
A collection of Visual Studio Code snippets useful for writing ERB
0.6.0 - Added 2 new tags used in Rails 7
0.5.0 - Added cl_image_path
-> clp
0.1.0 -> 0.3.0 - Added a couple more snippets
0.0.6 - Changed gif showcase
0.0.5 - New helpers (cloudinary image tag, time ago in words, simple form, etc.)
0.0.3 ~ 0.0.4 - Syntax fixed
0.0.2 - First release
These snippets can now be installed via VS Code Marketplace.
- Download erb-vscode-snippets.vsix
- Press
F1
enterext vsix
- Select
erb-vscode-snippets.vsix
- You can just copy the snippets from snippets.json
- Go to
Preferences > User Snippets
and entererb
- Paste the snippets code
Snippet | Tab Trigger | Output |
---|---|---|
ERB comment tag | pc | <%# %> |
each helper |
each | `<% @things.each do |
else tag |
else | <% else %> |
elsif tag |
elsif | <% elsif %> |
end tag |
end | <% end %> |
ERB no display tag | er | <% %> |
form_for helper |
ff | `<%= form_for(@ ) do |
if / else block |
ife | <% if %>...<% else %>...<% end %> |
if block |
if | <% if %>...<% end %> |
label_tag helper |
lblt | <%= label_tag ..., ... %> |
link_to helper |
lt | <%= link_to ..., ... %> |
ERB display tag | pe | <%= %> |
submit_tag helper |
st | <%= submit_tag ..., ... %> |
text_field_tag helper |
tft | <%= text_field_tag ..., ... %> |
unless block |
unless | <% unless %>...<% end %> |
image_tag helper |
it | <%= image_tag ..., ... %> |
cl_image_tag helper |
clt | <%= cl_image_tag(...) %> |
time_ago_in_words helper |
tw | <%= time_ago_in_words(...) %> |
simple_form_for helper |
sf | `<%= simple_form_for do |
simple_form_for nested helper |
sfn | `<%= simple_form_for [mod1, mod2] do |
f.input helper tag for simple form |
fi | <%= f.input ... %> |
hidden_field_tag helper tag |
hft | <%= hidden_field_tag ..., ... %> |
f.submit helper tag for simple form |
ft | <%= f.submit ... %> |
link_to_if helper tag |
lft | <%= link_to_if ..., ... %> |
javascript_pack_tag helper tag |
jpt | <%= javascript_pack_tag ... %> |
cl_image_path helper |
clp | <%= cl_image_path (<model>) %> |
turbo_frame_tag helper |
tf | <%= turbo_frame_tag ... %> |
turbo_stream_from helper |
ts | <%= turbo_stream_from ... %> |
Some of the above output examples are broken in Github Markdown (I'm not sure why), but works perfectly on VSCode's MD preview
Released under WTFPL, Version 2