TextMate-like Template Syntax for RADRails
UPDATE: Dr Nic carried the torch and converted all of TextMates snippets to radrails templates. These templates will also be included in the next RADRails release 0.7.2 which will come out the week of November 20th. If you cant wait, read Dr Nic’s post now and get his updated templates.
Now TextMate users can migrate to RADRails even easier after their 30-day Trial period is over.
I have gone through most of the Rails commands in TextMate and made equivalent templates in RADRails. If anything it will make it easier for rails developers to move back and forth between the two most popular IDEs.
Download: 2006-09-18.RADRails-TextMate_Templates-v1.xml
(right click and Save As..)
Instructions
In RADRails:
- Window -> Preferences -> Ruby -> Templates
- Import…
- Browse to the template file.
- Hit ‘OK’ and prepare for some down and dirty ball cupping
In a Ruby editor type your favourite TextMate command then hit
habtm<ctrl+space> (select textmate - has_and_belongs_to_many template)
Hit tab to cycle through available fields.
*Note: this is an initial release and only includes templates for Models, Views and Controllers. A few rails templates are missing, most notably, migrations.
In the next release I hope to include all TextMate HTML templates, tags, doctypes, etc. And maybe even a little extra goodies.
I am hoping that in RADRails versions to come that these templates are included with the release, and perhaps even Tab completion for templates so it works exactly like textmate.
Snippets (Tab Triggers)
Controllers
- rea : redirect_to(action)
- rei : redirect_to(index)
- rec : redirect_to(controller)
- reca : redirect_to(controller, action)
- recai : redirect_to(controller, action, index)
- ra : render(action)
- ral : render(action, layout)
- rf : render(file)
- rfu : render(file, use_full_path)
- ri : render(inline)
- ril : render(inline, locals)
- rit : render(inline, type)
- rl : render(layout)
- rn : render(nothing)
- rns : render(nothing, status)
- rp : render(partial)
- rpc : render(partial, collection)
- rpl : render(partial, locals)
- rpo : render(partial, object)
- rps : render(partial, status)
- rt : render(text)
- rtl : render(text,layout)
- rtit : render(text, layout => true)
- rts : render(text, status)
- rcea : render_component(action)
- rcec : render_component(controller)
- rceca : render_component(controller, action)
Models
- bt : belongs_to
- habtm : has_and_belongs_to_many
- ho : has_one
- hm : has_many
- va : validates_associated
- vaif : validates_associated if
- vc : validates_confirmation_of
- vcif : validates_confirmation_of if
- ve : validates_exclusion
- ve : validates_exclusion if
- vl : validates_length
- vp : validates_presence_of
- vpif : validates_presence_of if
- vu : validates_uniqueness_of
- vuif : validates_uniqueness_of if
Views
- forin : for .. in .. end
- ft : form_tag
- lia : link_to(action)
- liai : link_to(action, index)
- lic : link_to(controller)
- lica : link_to(controller, action)
- licai : link_to(controller, action, index)
Migrations (coming in next release)
...
HTML (more coming soon..)
- table : an html table
Link to my original post and discussion on the RADRails blog

adong
cool
Ben Kittrell
Good work man. Thanks a load.
Roman Heinrich
Thanks man, I was considering buying a Mac to use Textmate, but RadRails seems to offer the same functionality for any OS… ;) Just great!
Sébastien Grosjean
That’s look great ! Thanks for sharing.
Mark
“Now TextMate users can migrate to RADRails even easier after their 30-day Trial period is over.”
Are you serious? Why would they? RadRails may be nice for a lot of people, but TextMate is a full fledged Text Editor (and more!) and is a Mac application, which RadRails is definitely not. I don’t want to be harsh but RR can’t stand the comparison with TM.
“I was considering buying a Mac to use Textmate, but RadRails seems to offer the same functionality for any OS”
:D You obviously never used TextMate or even OS X to make assumptions like that!
Corban Brook
“Are you serious? Why would they? RadRails may be nice for a lot of people, but TextMate is a full fledged Text Editor (and more!) and is a Mac application, which RadRails is definitely not. I don’t want to be harsh but RR can’t stand the comparison with TM.”
Mark: TM is a good editor, but you are making the mistake comparing a text editor to an IDE. Sure the ruby editor within RadRails is not as functional as TextMate, but the other features in the development environment make RR ideal for RubyOnRails development. The textmate templates just improve the usability further.
Now its nice that TextMate is a mac application, but Ive been using Vi for years over terminal and I know speed isnt everything.
Textmate Bundles are great for doing the work for you, but once you get the content down im sure most Vi and Emacs users find it frustrating how lacking in features it is.
I myself use Vi whenever possible for editing on a mac and when in radrails i use viPlugin. viPlugin combined with a REAL IDE and TextMate templates make it a force to be reckoned with.
Perhaps you will someday find it useful when you need the power of a real IDE for your development. I certainly reached the point where vi was not meeting my needs for rails development and switched to RadRails.
tshine
Mark
Why waste everyones time with snide remarks and just tell us all what makes Textmate and OSX better than any other platform aside from the cute little “snippet” thing we’ve been doing with RR since day one? We’re anxiously awaiting your resonse. I mean, I’m sorry if you have stock invested in Textmate or something but I do believe you are bringing a “Text Editor” to an IDE fight.
Mark
Sorry I didn’t see the responses sooner.
I don’t have time to fight multiple wars at the same time, sorry. “Text Editor” vs IDE, TM vs Vi vs emacs, Mac vs the rest. Too much.
All I can say is I don’t see what an IDE could do that I can’t do in TM (for Rails). I may be dumb or something, but I’m not alone, as DHH and “Every single Rails Core contributer is running on Apple”[1] and because of TextMate apparently.[2]
Short quotes for the lazy: [1] “It’s been no secret that Apple is held in very high regard by the Rails community. Every single Rails Core contributer is running on Apple and the vast majority of Rails developers are too.”
[2] “TextMate is today without a doubt the most important OS X application on my machine. Most everything else has worthy alternatives, but TextMate is in a class of its own. It’s a big part of the reason that Ruby on Rails programmers are picking up Macs in droves. “
Looks like I’m not the only one thinking that there are things that make “Textmate and OSX better than any other platform aside from the cute little “snippet” thing we’ve been doing with RR since day one”. (BTW: I’m sure DHH worked on and with Rails using TM before you made any snippets.)
The difference between me and some you is: I tried both.
Mark
Why does it eats my links? I try without the http
Mark
Sorry. Another try with html links… If it doesn’t work, sorry again. Search the ror weblog and loudthinking.
1 and 2
Corban Brook
Mark:
I dont want to get into a war about which is the better editor. I will admit, i probably gave textmate as much a chance as you gave radrails.
As with anything when we invest ourselfs in a product it is hard to be open to and see the value in other options.
Like i said before, I am heavily invested in vi, others in emacs and TextMate. Which is better is completely subjective.
Adding the templates to RadRails was done strictly to leverage the TextMate functionality for those who wanted to use an IDE.
Now TextMate itself does include many IDE features, it is more then a mear editor. SVN support, Runs unit tests, Ruby scripts, and its extendable to include many other features.
So it is poor judgement for me to knock TextMate in any way. In the end you use what you are comfortable with and I think you should be open to that too.
Chris
Thanks for the template! It works great. Looking forward to the next release.