Linking to files in CF error messages

1 view
Skip to first unread message

Russ Johnson

unread,
Jul 20, 2009, 12:42:26 PM7/20/09
to cftextmate
I just blogged about how you can create links on the error messages in
ColdFusion and Railo so that when you click the error in the browser,
it will open that file in Textmate and jump to the line that the error
was caused on.

http://angry-fly.com/post.cfm/linking-to-files-in-coldfusion-errors

I dont know if this works on E but I would assume it would be the
same. I have it working on all of my error files in Railo and it took
about 2 minutes to do. I cant believe how simple this is but how much
time it saves digging through files.

If any of you try this with E or with the default ColdFusion 8 or 9
files, let me know and I can update the post with your results.

- Russ

Steve Ross

unread,
Jul 20, 2009, 12:50:46 PM7/20/09
to cftex...@googlegroups.com
Nice, I'd like to see a call in TM that if you have an include that it will grab the file name and you could hit a hot key and open that file.... that would be nice.
--
Steve Ross
web application & interface developer
http://blog.stevensross.com
[mobile] (912) 344-8113 [fax] (404) 592-6885
[ AIM / Yahoo! : zeriumsteven ] [googleTalk : nowhiding ]

Steve Ross

unread,
Jul 23, 2009, 7:57:29 PM7/23/09
to cftex...@googlegroups.com
Here ya go... this will open up any linked file, preferable if you have a project defined otherwise it probably isn't going to find your file. But, it will try, works with cfinclude, javascript src=, and href= (for css files)... let me know if there are anymore types i should include.

create a new command, give it a shorcut paste the command in below:



#!/usr/bin/env ruby
require "rexml/document"
require "#{ENV['TM_SUPPORT_PATH']}/lib/textmate.rb"
include REXML 


string = ENV['TM_CURRENT_LINE'].dup
if !string.empty?
  if !string.include?('script')
    r = string.scan(/\/\>/)
    if r.length == 0
      string.chop!
      string << "/>" 
    end
  end
  
  
  if ENV['TM_FILEPATH']
    current_path = File.dirname(ENV['TM_FILEPATH'].dup)
    puts ENV['TM_PROJECT_DIRECTORY']
    
    doc = Document.new string
      if doc.root
        path = doc.root.attributes['href'] || doc.root.attributes['src'] || doc.root.attributes['template']
      
        if ENV['TM_PROJECT_DIRECTORY']
          current_path = ENV['TM_PROJECT_DIRECTORY'].dup
        end
        puts file_path =  current_path + '/' + path
        TextMate.go_to :file => file_path
      end
  end
end

#===========

Steve Ross

unread,
Jul 23, 2009, 7:59:48 PM7/23/09
to cftex...@googlegroups.com
to clarify: put your cursor on any of these lines and hit the command you just created:

<script type="text/javascript" src="jscripts/jquery/js/jquery-ui-togglebox.js"></script>
<link type="text/css" href="style/jquery_custom.css" rel="stylesheet" />
<cfinclude template="/somefile.cfm"> 

just realized it isnt going to work with relative paths like ../../something.cfm I'll work on a fix

Russ Johnson

unread,
Aug 14, 2009, 3:59:57 PM8/14/09
to cftex...@googlegroups.com
Im not able to get this to work for some reason. I have tried absolute paths on files and everything.

Steve Ross

unread,
Oct 15, 2009, 10:27:06 AM10/15/09
to cftex...@googlegroups.com
I'm going to work on a fix for this... been extremely busy
Reply all
Reply to author
Forward
0 new messages