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 ... |
Last active
February 24, 2025 14:06
-
-
Save db0sch/57d2d8c8e3f478b183c68e8051fe3a01 to your computer and use it in GitHub Desktop.
ERB Snippets (in VS Code with the Ruby extension)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create an erb.json here: /Users/XXXX/Library/Application Support/Code/User/snippets/erb.json and paste this json: {
"ERB tags": {
"prefix": "er",
"body": ["<% $0 %>"],
"description": "Insert <% %>"
},
"print ERB tags": {
"prefix": "pe",
"body": ["<%= $0 %>"],
"description": "Insert <%= %>"
},
"if block": {
"prefix": "if",
"body": ["<% if $1 %>", " $0", "<% end %>"],
"description": "Insert <% if %>...<% end %>"
},
"if / else block": {
"prefix": "ife",
"body": ["<% if $1 %>", " $2", "<% else %>", " $0", "<% end %>"],
"description": "Insert <% if %>...<% else %>...<% end %>"
},
"else tag": {
"prefix": "else",
"body": ["<% else %>"],
"description": "Insert <% else %>"
},
"elsif tag": {
"prefix": "elsif",
"body": ["<% elsif $0 %>"],
"description": "Insert <% elsif %>"
},
"unless block": {
"prefix": "unless",
"body": ["<% unless $1 %>", " $0", "<% end %>"],
"description": "Insert <% unless %>...<% end %>"
},
"end block": {
"prefix": "end",
"body": ["<% end %>"],
"description": "Insert <% end %>"
},
"each helper": {
"prefix": "each",
"body": ["<% @things.each do |thing| %>", " $0", "<% end %>"],
"description": "Insert <% @things.each do %>...<% end %>"
}
}