6184 Injector Editor 25 Basil Gren 2.5 4669 toXXIc 2016-01-25 1.04


Compatible with:  IntelliJ IDEA RubyMine
4 669
Provides fast Ruby code injections into erb files and ruby strings. Injector makes replacements as fast as you type shortcut text and also provides additional features. Examples:
  • '%%' --> <% | %>
  • '%=' --> <%= | %>
  • '%-' --> <%- | -%>
  • '##' --> <%# | %>
Templates can be added and/or changed in settings. See details in General Usage section.
Feel free to report bugs and your suggestions to provided e-mail.

Download plugin

Recent change notes

Fixed options saving and updated default templates

General usage instructions

Plugin provides fast ruby code injections. After typing shortcut text, it's replaced immediately by corresponding template. Examples are listed below:

  • '%%' --> <%- | -%>

  • '%=' --> <%= | -%>

  • '%-' --> <% | %>

  • '##' --> <%# | -%>

Templates are not inserted if cursor is already in Ruby-code block. You can change existing templates of define your own templates in settings dialog which is accessible in IDE Settings or by right-click on injector icon in status bar.
Injector provides insertion of '#{}' into Ruby strings. When cursor is placed in Ruby string, shortcut (default '##') is expanded info '#{}' and if string is non-interpolating (single-quoted), it's automatically converted to interpolating (double-quoted) string. This behavior and shortcut can be changed in settings.
To enable or disable Injector you can click on injector icon in the status bar or press default shortcut Ctrl+Comma(,).
Finally, v1.0 is finished.
Unfortunately, templates now are hard-coded, but customizing is the next step of development. I just need to implement settings for the plugin.
Definitely better. Can the templates be customized, since I definitely like using the - symbols after the % (ensures that the injection line does not create a blank line in the output, good for saving some bandwidth and cleaner output).
Dear Dmitry, thank you very much for your feedback. Actually I wrote the plugin to learn how to make plugins for IntelliJ platform and to speed up template editing with my style of coding. It was good for me because I mostly insert ruby code into ready html templates, so many bugs were unseen for me. Now having some feedback I reworked Injector to make it much more comfortable in use. From this version you can freely use '=', '#', '%' and '-' characters as usually, because now replacement is made after typing several characters instead of one. Please, try new version and I hope you will find it useful now. Please, feel free to report any bugs and suggestions here or via e-mail.
Here are some live templates I use daily instead of this plugin... Maybe someone can instruct me how to release those maybe in some importable format on github.

ERB files only, | = cursor or $END$ varaible.

%- -> <%- | %>
%-- -> <%- | -%>
%= -> <%= | %>
end -> <%- end -%>
%=t -> <%= t("|") %>
This plugin kind of sucks. I replaced all it’s uses with live templates, and then some. It has MANY drawbacks, allow me to elaborate:

1) Typing simple things like = and - automatically turns into tags. Which is really bad when trying to type the following: <input type="button" class="foo-bar"> as it keeps escaping. I hit this situation more times than I actually used the feature. Sure you can undo but why, when the more common use for me is %- -> <- | %> and I can go crazy like %=t -> <%= t("|") %> etc…

2) You can no longer type %, -, =, # into live templates with this plugin. That’s right I started copy-pasting from vim to get the characters into live templates. That is beyond awful.

3) The to undo is stupid. It needs to be very smart about it because a VERY common case is typing `class=` -> `class<= | %>` -> `class<= "foo %>` [OPSE, backspace, oh wait i can't undo that expansion anymore]

I’d honestly remove this plugin and add a few live templates. This plugin is more harm than good.
Please  sign in  to leave a comment.