/vscode-erb-helpers

A collection of Visual Studio Code snippets useful for coding ERB templates

Do What The F*ck You Want To Public LicenseWTFPL

ERB-VSCode-Snippets

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

VSCode marketplace link

Version

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

Features

feature

Installation

These snippets can now be installed via VS Code Marketplace.

Manual installation with extension

  1. Download erb-vscode-snippets.vsix
  2. Press F1 enter ext vsix
  3. Select erb-vscode-snippets.vsix

Manual installation without extension

  1. You can just copy the snippets from snippets.json
  2. Go to Preferences > User Snippets and enter erb
  3. Paste the snippets code

Snippets and Bindings

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 ... %>

Note

Some of the above output examples are broken in Github Markdown (I'm not sure why), but works perfectly on VSCode's MD preview

License

Released under WTFPL, Version 2