Permalink
Browse files

maximum awesome

  • Loading branch information...
0 parents commit dc030abf25f135599f90894821cdbce5b16508c0 @mislav committed Nov 9, 2009
Showing with 139 additions and 0 deletions.
  1. +41 −0 Commands/Execute Line : Selection as JavaScript.tmCommand
  2. +32 −0 Commands/Run javascript.tmCommand
  3. +51 −0 README.md
  4. +15 −0 info.plist
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env macruby
+require 'lyndon'
+js = Lyndon::Runtime.new
+js.eval 'window.console.log = function(msg) { Ruby.puts(msg) }'
+
+selection = ENV['TM_SELECTED_TEXT']
+
+begin
+ print(selection ? " " : "\n")
+ out = js.eval(STDIN.read)
+rescue Object
+ out = $!.class.to_s
+end
+
+unless WebUndefined === out
+ print out
+ puts unless selection
+end</string>
+ <key>fallbackInput</key>
+ <string>line</string>
+ <key>input</key>
+ <string>selection</string>
+ <key>keyEquivalent</key>
+ <string>^E</string>
+ <key>name</key>
+ <string>Execute Line / Selection as JavaScript</string>
+ <key>output</key>
+ <string>afterSelectedText</string>
+ <key>scope</key>
+ <string>source.js</string>
+ <key>uuid</key>
+ <string>BD558331-52F5-4449-A62F-A772C1F6E12F</string>
+</dict>
+</plist>
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>beforeRunningCommand</key>
+ <string>nop</string>
+ <key>command</key>
+ <string>#!/usr/bin/env macruby
+require 'lyndon'
+js = Lyndon::Runtime.new
+js.eval 'window.console.log = function(msg) { Ruby.puts(msg) }'
+
+out = js.eval(STDIN.read)
+
+require 'cgi'
+print "&lt;pre&gt;&lt;code&gt;"
+puts CGI.escapeHTML(out.inspect)
+puts "&lt;/code&gt;&lt;/pre&gt;"</string>
+ <key>input</key>
+ <string>document</string>
+ <key>keyEquivalent</key>
+ <string>@r</string>
+ <key>name</key>
+ <string>Run JavaScript</string>
+ <key>output</key>
+ <string>showAsHTML</string>
+ <key>scope</key>
+ <string>source.js</string>
+ <key>uuid</key>
+ <string>270B531B-34CB-4953-A2C4-1118551002D1</string>
+</dict>
+</plist>
@@ -0,0 +1,51 @@
+Execute JavaScript in TextMate
+==============================
+
+This is a TextMate bundle for the excellent [Lyndon][].
+
+1. Get [MacRuby][],
+2. Get Lyndon. Do so with [rip][]:
+
+ rip install git://github.com/defunkt/lyndon.git
+
+ Or rubygems:
+
+ [sudo] macgem install lyndon
+
+3. Install Lyndon.tmbundle:
+
+ git clone git://github.com/mislav/Lyndon.tmbundle.git \
+ "~/Library/Application Support/TextMate/Bundles"
+
+4. Maximum awesome.
+
+Bundle commands
+---------------
+
+Shortcuts are the same as equivalents in Ruby documents:
+
+* ⌘R -- run JavaScript document
+* ⌃⇧E -- run line / selection as JavaScript
+
+*(Make sure you have your textmate document set to "JavaScript".)*
+
+Try it on
+---------
+
+Here's a sample document:
+
+ function camelize(string){
+ return string.replace(/-(.)/g, function(_, c){ return c.toUpperCase() })
+ }
+
+ camelize('webkit-border-radius')
+
+Hitting ⌘R should produce:
+
+ "WebkitBorderRadius"
+
+You're done.
+
+[lyndon]: http://github.com/defunkt/lyndon
+[macruby]: http://www.macruby.org/downloads.html
+[rip]: http://hellorip.com/about.html
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>name</key>
+ <string>Lyndon</string>
+ <key>ordering</key>
+ <array>
+ <string>270B531B-34CB-4953-A2C4-1118551002D1</string>
+ <string>BD558331-52F5-4449-A62F-A772C1F6E12F</string>
+ </array>
+ <key>uuid</key>
+ <string>B11D041F-00CB-4031-8454-98CD9A4C9FE8</string>
+</dict>
+</plist>

0 comments on commit dc030ab

Please sign in to comment.