Thanks, I didn’t know about TextMate.system(…) – that’s exactly what I was looking for. �

It took a while until I got the escaping right, here’s what I ended up with:

def link_to(title, local_path)
  url = URI.escape("file://#{local_path}")
  title = CGI.escape_html(title)
  %{<a onclick='TextMate.system("open #{Shellwords.escape(url)}"); return false;' href='#{url}'>#{title}</a>}
end

Gist with the complete setup: https://gist.github.com/noniq/9289157

Stefan

Am 01.03.14 07:15, schrieb Allan Odgaard:

On 1 Mar 2014, at 9:20, Stefan Daschek wrote:

Is it possible to force specific links in the HTML output window to open in the default browser […] I have a Rails project where the testsuite already creates a dump of the HTML page for each failed feature spec. Now I’m trying to extend RSpec’s TextMateFormatter to include links to these files. Works so far, but I need to open the saved HTML pages in my default browser so that I have my usual developer tools around for debugging.

Given that you are modifying the generated output, you can change the link to use JavaScript and TextMate.system(), example:

<script>
function open_url(url) {
  TextMate.system("open '" + url + "'");
}
</script>

<a href="#" onClick="open_url('http://macromates.com/'); return true;">Open Website</a>


_______________________________________________
textmate mailing list
textmate@lists.macromates.com
http://lists.macromates.com/listinfo/textmate