Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created February 18, 2011 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timruffles/834006 to your computer and use it in GitHub Desktop.
Save timruffles/834006 to your computer and use it in GitHub Desktop.
textmate backbone view
#!/usr/bin/ruby
require 'pathname'
proj_dir = Pathname.new(ENV['TM_PROJECT_DIRECTORY'])
file_path = Pathname.new(ENV['TM_FILEPATH'])
path = file_path.relative_path_from(proj_dir).to_s
module_name = path.gsub(/\.js$/,'')
moddy = module_name.split('/').last
class_name = (moddy.capitalize.gsub(/_(\w)/) {|str| $1.upcase})
puts "define('#{module_name}',[],function() {
var #{class_name} = Backbone.View.extend({
events: {
},
tagName: 'div',
className: '#{moddy}',
constructor: function() {
}
})
return #{class_name}
})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment