Sublime Forum

Insert empty erb tag?

#1

Anticipating deep shame on this, but I need someone to point out this functionality for me.

I could swear there used to be a built-in keyboard combo/snippet that would insert an empty erb tag–by which I mean:

<%= | %>

(where the pipe there signifies cursor position).

Not finding any such thing now in command palette or menus (syntax is set to ‘HTML (Rails)’). There are bunches of snips for particular view helpers (form_for, link_to, etc) but nothing so bare bones.

I suppose I can make my own snippet, but this makes me wonder if I’ve got some fundamental problem w/my config (or understanding) of sublime.

Can anybody throw me a clue here?

Thanks!

-Roy

0 Likes

#2

The way, how to create own snippets, you’ll find here: http://docs.sublimetext.info/en/latest/extensibility/snippets.html
I’ve made this for you. The trigger is “erb”, you can change this, if you like.
Put this stuff in an file and store this as “any_Filename.sublime-snippet” in your folder “…\Data\Packages”
Write “erb” in ST and hit Tab, thats all.

<snippet>
    <content><![CDATA[<%= ${1} %>]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>erb</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.html</scope>
    <description>Empty Erb Tag</description>
</snippet>
0 Likes

#3

Thanks BugFix! I’ll use that. I guess it really isn’t in the core rails package then. Weird–maybe I’m remembering ST2 (or the ‘e’ text editor)? I haven’t done rails stuff in a looong time…

0 Likes