Ruby on Rails
TextMateTipsAndTrix (Version #23)

TextMate is a code and markup editor for OS X that ships with syntax highlighting and other goodies for Ruby (and Rails). Its official site is http://macromates.com/

Tips and Trix for TextMate

Share your tips and trix

Rails 2 style bundle

rails 2 style html.erb etc. templates are not interpreted correctly by the textmate rails bundle.
To change this, go to Bundles > Bundle Editor
Open Rails > HTML (Rails) and change the 2nd line to

fileTypes = ( ‘rhtml’, ‘html.erb’ );

and also the Ruby on Rails node, line 2 to:

fileTypes = ( ‘rxml’, ‘xml.erb’ );

Q: is there an updated edge-rails bundle out there?

Textmate Footnotes Plugin

footnotes is a rails plugin that makes trace links clickable in the browser in development mode. Very cool. “Read more”:Textmate Footnotes Plugin

Generate a cheatsheet for your preferred bundles in TextMate

There’s a neat little Rails application at http://keyref.octopod.info/ that you can paste TextMate’s shortcut list into (Command-Option-Control-k from an edit window) and it’ll let you pick up to eight bundles, then email you a PDF cheatsheet for them.

TODO LIST – rails version ;)

This is an modified version of the default TODO command in TextMate

The modification:

  • Search the whole project path ($TMPROJECT_DIRECTORY)_
  • Search only .rb & .rhtml files (for speed)
  • Some html changes.

Howto:

  1. Open the bundle editor
  2. Create a new Command
  3. Set Input: to ‘None’
  4. Set Output: to Show as HTML
  5. Set a Activation trigger.
  6. Copy the code below in the command(s) window

WorkPath="$TM_PROJECT_DIRECTORY"
WorkPath="${WorkPath// /%20}/" # turn spaces into %20
export WorkPath

cat <<EOF
 <html><head><style>
 body { font: 12px 'Lucida Grande' }
 </style></head><body>
 <center><h1> - TODO LIST - </h1></center>
<div style="border-top: 1px #cccccc dotted;">&nbsp;</div>
 <ul>
EOF

cd "$TM_PROJECT_DIRECTORY"
find . -name '.svn' -type d -prune -or -name '*.rb' -type f -exec grep -HinwE "TODO|FIXME|FIX ME" '{}' \; -or -name '*.rhtml' -type f -exec grep -HinwE "TODO|FIXME|FIX ME" '{}' \; | perl -pe '$|=1; s/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g; s!(.*?):(.*?):.*?(?:TODO|FIXME|FIX ME)[:,]?(.*)$!<li><a href="txmt://open?url=file://$ENV{'WorkPath'}/$1&line=$2"><small>$1</small></a>:<br/><div style="margin: 10px">$3</div></li>!i'

echo "</ul>"
echo '<center><div style="border-top: 1px #cccccc dotted; margin-top: 20px; color: #aaaaaa;"><br/><i>Done.</i></div></center>'
echo "<body>"

Then add

TODO this must be fixed
to one of your source files,
save and press your activation trigger and enyoy.

the command above returns ‘/bin/bash: line 1: WorkPath=/: No such file or directory’ for me)

You can add this snippet too


#TODO `date +d-m-%Y` ${1:what you want}

and trigger it to todo for insert a dated TODO easily

the above date example does not work for me. It does not get parsed.)

TextMate is a code and markup editor for OS X that ships with syntax highlighting and other goodies for Ruby (and Rails). Its official site is http://macromates.com/

Tips and Trix for TextMate

Share your tips and trix

Rails 2 style bundle

rails 2 style html.erb etc. templates are not interpreted correctly by the textmate rails bundle.
To change this, go to Bundles > Bundle Editor
Open Rails > HTML (Rails) and change the 2nd line to

fileTypes = ( ‘rhtml’, ‘html.erb’ );

and also the Ruby on Rails node, line 2 to:

fileTypes = ( ‘rxml’, ‘xml.erb’ );

Q: is there an updated edge-rails bundle out there?

Textmate Footnotes Plugin

footnotes is a rails plugin that makes trace links clickable in the browser in development mode. Very cool. “Read more”:Textmate Footnotes Plugin

Generate a cheatsheet for your preferred bundles in TextMate

There’s a neat little Rails application at http://keyref.octopod.info/ that you can paste TextMate’s shortcut list into (Command-Option-Control-k from an edit window) and it’ll let you pick up to eight bundles, then email you a PDF cheatsheet for them.

TODO LIST – rails version ;)

This is an modified version of the default TODO command in TextMate

The modification:

  • Search the whole project path ($TMPROJECT_DIRECTORY)_
  • Search only .rb & .rhtml files (for speed)
  • Some html changes.

Howto:

  1. Open the bundle editor
  2. Create a new Command
  3. Set Input: to ‘None’
  4. Set Output: to Show as HTML
  5. Set a Activation trigger.
  6. Copy the code below in the command(s) window

WorkPath="$TM_PROJECT_DIRECTORY"
WorkPath="${WorkPath// /%20}/" # turn spaces into %20
export WorkPath

cat <<EOF
 <html><head><style>
 body { font: 12px 'Lucida Grande' }
 </style></head><body>
 <center><h1> - TODO LIST - </h1></center>
<div style="border-top: 1px #cccccc dotted;">&nbsp;</div>
 <ul>
EOF

cd "$TM_PROJECT_DIRECTORY"
find . -name '.svn' -type d -prune -or -name '*.rb' -type f -exec grep -HinwE "TODO|FIXME|FIX ME" '{}' \; -or -name '*.rhtml' -type f -exec grep -HinwE "TODO|FIXME|FIX ME" '{}' \; | perl -pe '$|=1; s/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g; s!(.*?):(.*?):.*?(?:TODO|FIXME|FIX ME)[:,]?(.*)$!<li><a href="txmt://open?url=file://$ENV{'WorkPath'}/$1&line=$2"><small>$1</small></a>:<br/><div style="margin: 10px">$3</div></li>!i'

echo "</ul>"
echo '<center><div style="border-top: 1px #cccccc dotted; margin-top: 20px; color: #aaaaaa;"><br/><i>Done.</i></div></center>'
echo "<body>"

Then add

TODO this must be fixed
to one of your source files,
save and press your activation trigger and enyoy.

the command above returns ‘/bin/bash: line 1: WorkPath=/: No such file or directory’ for me)

You can add this snippet too


#TODO `date +d-m-%Y` ${1:what you want}

and trigger it to todo for insert a dated TODO easily

the above date example does not work for me. It does not get parsed.)