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 ... |
-
-
Save db0sch/57d2d8c8e3f478b183c68e8051fe3a01 to your computer and use it in GitHub Desktop.
@dmilon actually, the trailing back tick was there, but there is a conflict with the |
pipe character and the markdown parser, probably as we using a markdown table here (and |
is the syntax to seperate cells)
And how can we import them?
By installing the Ruby extension on VSCode
"This extension is not available anymore. Use Ruby LSP instead"
Since i changed to Ruby LSP, i my favourite snippets don't work anymore.
Do you know how i can go back to the previous version ?
Good point. I need to investigate.
In one of the rails lectures (Models and CRUD) the lecturer mentions a "lt" shortcut to create a link_to. Is this a pipe dream or is it possible to get?
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
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 🙏
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 %>"
}
}
Missing the closing back tick here