mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-12-12 16:34:18 +00:00
* Start again the textmate snippet importations, with better
textmate_import.rb and yasnippet.el
This commit is contained in:
@@ -1 +0,0 @@
|
||||
text-mode
|
||||
@@ -1,149 +0,0 @@
|
||||
(defvar yas/rails-root-cache nil)
|
||||
|
||||
;; stolen from rinari-mode's rinari-root
|
||||
(defun yas/rails-root (&optional dir)
|
||||
(or dir (setq dir default-directory))
|
||||
(or (and (featurep 'rinari) (rinari-root dir))
|
||||
yas/rails-root-cache
|
||||
(if (file-exists-p (expand-file-name
|
||||
"environment.rb" (expand-file-name "config" dir)))
|
||||
(set (make-local-variable 'yas/rails-root-cache) dir)
|
||||
(let ((new-dir (expand-file-name (file-name-as-directory "..") dir)))
|
||||
;; regexp to match windows roots, tramp roots, or regular posix roots
|
||||
(unless (string-match "\\(^[[:alpha:]]:/$\\|^/[^\/]+:\\|^/$\\)" dir)
|
||||
(yas/rails-root new-dir))))))
|
||||
|
||||
;; stolen from rinari-mode's rinari-extract-partial
|
||||
(defun yas/rails-extract-partial (begin end partial-name)
|
||||
(interactive "r\nsName your partial: ")
|
||||
(let* ((path (buffer-file-name)) ending)
|
||||
(if (string-match "view" path)
|
||||
(let ((ending (and (string-match ".+?\\(\\.[^/]*\\)$" path)
|
||||
(match-string 1 path)))
|
||||
(partial-name
|
||||
(replace-regexp-in-string "[[:space:]]+" "_" partial-name)))
|
||||
(kill-region begin end)
|
||||
(if (string-match "\\(.+\\)/\\(.+\\)" partial-name)
|
||||
(let ((default-directory (expand-file-name (match-string 1 partial-name)
|
||||
(expand-file-name ".."))))
|
||||
(find-file (concat "_" (match-string 2 partial-name) ending)))
|
||||
(find-file (concat "_" partial-name ending)))
|
||||
(yank) (pop-to-buffer nil)
|
||||
(insert (concat "<%= render :partial => '" partial-name "' %>\n")))
|
||||
(message "not in a view"))))
|
||||
;;;
|
||||
;;; The TextMate "intelligent" migration snippet
|
||||
;;
|
||||
(defvar yas/rails-intelligent-migration-snippet-bits
|
||||
'((:rename_column . ((:up . "rename_column :${1:table_name}, :${2:column_name}, :${3:new_column_name}$0")
|
||||
(:down . "rename_column :$1, :$3, :$2" )))
|
||||
|
||||
(:rename_column_continue . ((:up . "rename_column :${1:table_name}, :${2:column_name}, :${3:new_column_name}\nmncc$0")
|
||||
(:down . "rename_column :$1, :$3, :$2" )))
|
||||
|
||||
(:rename_table . ((:up . "rename_table :${1:old_table_name}, :${2:new_table_name}$0")
|
||||
(:down . "rename_table :$2, :$1" )))
|
||||
|
||||
(:rename_table_continue . ((:up . "rename_table :${1:old_table_name}, :${2:new_table_name}\nmntc$0")
|
||||
(:down . "rename_table :$2, :$1" )))
|
||||
|
||||
(:add_remove_column . ((:up . "add_column :${1:table_name}, :${2:column_name}, :${3:string}$0")
|
||||
(:down . "remove_column :$1, :$2" )))
|
||||
|
||||
(:add_remove_column_continue . ((:up . "add_column :${1:table_name}, :${2:column_name}, :${3:string}\nmarcc$0")
|
||||
(:down . "remove_column :$1, :$2" )))
|
||||
|
||||
(:remove_add_column . ((:up . "remove_column :${1:table_name}, :${2:column_name}$0")
|
||||
(:down . "add_column :$1, :$2, :$3{string}" )))
|
||||
|
||||
(:create_drop_table . ((:up . "create_table :${1:table_name}, :force . true do |t|\nt.$0\nt.timestamps\nend")
|
||||
(:down . "drop_table :$1" )))
|
||||
|
||||
(:change_change_table . ((:up . "change_table :${1:table_name} do |t|\nt.$0\nend")
|
||||
(:down . "change_table :$1 do |t|\nend" )))
|
||||
|
||||
(:add_remove_index . ((:up . "add_index :${1:table_name}, :${2:column_name}$0")
|
||||
(:down . "remove_index :$1, :$2" )))
|
||||
|
||||
(:add_remove_unique_index . ((:up . "add_index :${1:table_name}, ${2:[:${3:column_name}${4:, :${5:column_name}}]}, :unique . true$0")
|
||||
(:down . "remove_index :$1, :column . $2" )))
|
||||
|
||||
(:add_remove_named_index . ((:up . "add_index :${1:table_name}, [:${2:column_name}${3:, :${4:column_name}}], :name . \"${5:index_name}\"${6:, :unique . true}$0")
|
||||
(:down . "remove_index :$1, :name . :$5" )))))
|
||||
|
||||
|
||||
(defun yas/rails-intelligent-migration-snippet (type)
|
||||
(let* ((start (point))
|
||||
(end (save-excursion
|
||||
(search-forward-regexp "^\s*def\sself\.down" nil 'noerror)))
|
||||
(up (aget (aget yas/rails-intelligent-migration-snippet-bits type) :up))
|
||||
(down (aget (aget yas/rails-intelligent-migration-snippet-bits type) :down))
|
||||
(snippet
|
||||
(and up down start end (concat up
|
||||
(buffer-substring-no-properties start end)
|
||||
"\n" down))))
|
||||
(when snippet
|
||||
(delete-region start end)
|
||||
(yas/expand-snippet snippet))))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-intelligent-migration-snippet-condition-p
|
||||
"Non-nil if an \"intelligent\" migration snippet should be expanded"
|
||||
(and (yas/rails-migration-p)
|
||||
(not (yas/rails-in-create-table-p))
|
||||
(not (yas/rails-in-change-table-p))
|
||||
(yas/rails-in-ruby-block-like "self\.up")))
|
||||
|
||||
(defun yas/rails-in-ruby-block-like (regexp)
|
||||
(save-excursion
|
||||
(ruby-accurate-end-of-block)
|
||||
(ruby-backward-sexp)
|
||||
(search-forward-regexp regexp (line-end-position) t)))
|
||||
|
||||
;;; conditions
|
||||
(yas/define-condition-cache
|
||||
yas/rails-in-create-table-p
|
||||
"Non-nil if point is inside a 'create_table' method call."
|
||||
(yas/rails-in-ruby-block-like "create_table"))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-in-change-table-p
|
||||
"Non-nil if point is inside a 'change_table' method call."
|
||||
(yas/rails-in-ruby-block-like "change_table"))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-model-p
|
||||
"Non-nil if the current buffer is a rails model."
|
||||
(and (yas/rails-root)
|
||||
(string-match "app/models/$" default-directory)))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-view-p
|
||||
"Non-nil if the current buffer is a rails view."
|
||||
(and (yas/rails-root)
|
||||
(string-match "app/views/" default-directory)))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-controller-p
|
||||
"Non-nil if the current buffer is a rails controller."
|
||||
(and (yas/rails-root)
|
||||
(string-match "app/controllers/$" default-directory)))
|
||||
|
||||
(yas/define-condition-cache
|
||||
yas/rails-migration-p
|
||||
"Non-nil if the current buffer is a rails migration."
|
||||
(and (yas/rails-root)
|
||||
(string-match "db/migrate/" default-directory)))
|
||||
|
||||
(defun yas/rails-activate-maybe ()
|
||||
(when (and yas/minor-mode
|
||||
(yas/rails-root))
|
||||
(set (make-local-variable 'yas/mode-symbol) 'rails-mode)))
|
||||
|
||||
(defadvice cd (after yas/rails-on-cd-activate activate)
|
||||
"Set `yas/mode-symbol' to `rails-mode' so that rails snippets
|
||||
are recognized. Stolen from `rinari-mode' more or`' less."
|
||||
(setq yas/rails-root-cache nil)
|
||||
(yas/rails-activate-maybe))
|
||||
|
||||
(add-hook 'yas/minor-mode-hook 'yas/rails-activate-maybe)
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: crw
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: cattr_accessor
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
cattr_accessor :${0:attr_names}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: mrw
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: mattr_accessor
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
mattr_accessor :${0:attr_names}
|
||||
@@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: returning
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: returning do |variable| … end
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
returning ${1:variable} do${2:$(if (string= "" yas/text) "" " |")}${2:v}${2:$(if (string= "" yas/text) "" "|")}
|
||||
$0
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: xdelete
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: xhr delete
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
xhr :delete, :${1:destroy}, :id => ${2:1}$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: xget
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: xhr get
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
xhr :get, :${1:show}${2:, :id => ${3:1}}$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: xpost
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: xhr post
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
xhr :post, :${1:create}, :${2:object} => { $3 }
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: xput
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: xhr put
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: bt
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: belongs_to
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
belongs_to :${1:object}${2:, :class_name => "${3:${1:$(replace-regexp-in-string "_" "" (capitalize yas/text))}}", :foreign_key => "${4:$1_id}"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: habtm
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: has_and_belongs_to_many
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:$1_id}"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: hm
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: has_many
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: hmt
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: has_many (through)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:$2_table_foreign_key_to_$1_table}}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: hmd
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: has_many :dependent => :destroy
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
has_many :${1:object}s${2:, :class_name => "$1", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ho
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: has_one
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_create
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_create
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftd
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_destroy
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_destroy
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: afts
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_save
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_save
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftu
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_update
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_update
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftv
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_validation
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_validation
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftvoc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_validation_on_create
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_validation_on_create
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: aftvou
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: after_validation_on_update
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
after_validation_on_update
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_create
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_create
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befd
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_destroy
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_destroy
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befs
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_save
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_save
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befu
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_update
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_update
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befv
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_validation
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_validation
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befvoc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_validation_on_create
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_validation_on_create
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: befvou
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: before_validation_on_update
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
before_validation_on_update
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tre
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column(s) rename
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.rename(:${1:old_column_name}, :${2:new_column_name})
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.rename (tre)
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.rename(:${1:old_column_name}, :${2:new_column_name})
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: mcol
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Add / Remove Column
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :add_remove_column)
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: marcc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Add / Remove Several Columns (marcc)
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :add_remove_column_continue)
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: mcol
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Add / Remove Several Columns
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :add_remove_column_continue)
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: mcol
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Remove / Add Column
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :remove_add_column)
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: mncc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Rename / Rename Several Columns (mncc)
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :rename_column_continue)
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: mcol
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Rename / Rename Several Columns
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :rename_column_continue)
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: mcol
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Rename / Rename Column
|
||||
# condition: (yas/rails-intelligent-migration-snippet-condition-p)
|
||||
# --
|
||||
(yas/rails-intelligent-migration-snippet :rename_column)
|
||||
@@ -1,16 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: cla
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Create controller class
|
||||
## condition: "source.ruby"
|
||||
# --
|
||||
class ${1:Model}Controller < ApplicationController
|
||||
before_filter :find_${2:model}
|
||||
|
||||
$0
|
||||
|
||||
private
|
||||
def find_${2}
|
||||
@$2 = ${3:$1}.find(params[:id]) if params[:id]
|
||||
end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: flash
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: flash[…]
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
flash[:${1:notice}] = "${2:Successfully created...}"$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: verify
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: verify — render
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: verify
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: verify — redirect
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'}
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcbi
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column binary
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcb
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column boolean
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.boolean :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcda
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column date
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.date :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcdt
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column datetime
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.datetime :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcd
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column decimal
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcf
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column float
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.float :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tci
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column integer
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.integer :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcl
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column lock_version
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.integer :lock_version, :null => false, :default => 0
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcr
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column(s) references
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcs
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column string
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.string :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tct
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column text
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.text :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcti
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column time
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.time :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tcts
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column timestamp
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.timestamp :${1:title}
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: tctss
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Table column timestamps
|
||||
# condition: (and (yas/rails-migration-p) (or (yas/rails-in-create-table-p) (yas/rails-in-change-table-p)))
|
||||
# --
|
||||
t.timestamps
|
||||
$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.binary (tcbi)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.binary :${1:title}${2:, :limit => ${3:2}.megabytes}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.boolean (tcb)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.boolean :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.date (tcda)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.date :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.datetime (tcdt)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.datetime :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.decimal (tcd)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.float (tcf)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.float :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.integer (tci)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.integer :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.lock_version (tcl)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.integer :lock_version, :null => false, :default => 0
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.references (tcr)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.string (tcs)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.string :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.text (tct)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.text :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.time (tcti)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.time :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.timestamp (tcts)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.timestamp :${1:title}
|
||||
t.$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: t.
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: t.timestamps (tctss)
|
||||
# condition: (and (yas/rails-migration-p) (yas/rails-in-create-table-p))
|
||||
# --
|
||||
t.timestamps
|
||||
t.$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Dump DB to schema.rb
|
||||
## binding: "^|"
|
||||
## condition: "source.ruby.rails, source.yaml"
|
||||
# --
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Load schema.rb to DB
|
||||
## binding: "^|"
|
||||
## condition: "source.ruby.rails, source.yaml"
|
||||
# --
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Migrate to Current
|
||||
## binding: "^|"
|
||||
## condition: "source.ruby.rails, source.yaml"
|
||||
# --
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# key: [press tab twice to generate create_table]
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Drop / Create Table (Second Half)
|
||||
## condition: "meta.rails.migration - meta.rails.migration.create_table - meta.rails.migration.change_table"
|
||||
# --
|
||||
@@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ft
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: form_tag
|
||||
## condition: "text.html.ruby, text.haml"
|
||||
# --
|
||||
<% form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do %>
|
||||
$0
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# type: command
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Create Partial From Selection
|
||||
## binding: "^H"
|
||||
## condition: "source.ruby.rails, text.html.ruby, text.haml"
|
||||
# condition: mark-active
|
||||
# --
|
||||
(call-interactively 'yas/rails-extract-partial)
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: end
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: end (ERB)
|
||||
## condition: "text.html.ruby"
|
||||
# --
|
||||
<% end -%>
|
||||
@@ -1,13 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: for
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: for loop in rhtml
|
||||
## condition: "text.html.ruby"
|
||||
# --
|
||||
<% if !${1:list}.blank? %>
|
||||
<% for ${2:item} in ${1} %>
|
||||
$3
|
||||
<% end %>
|
||||
<% else %>
|
||||
$4
|
||||
<% end %>
|
||||
@@ -1,11 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ffe
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: form_for with errors
|
||||
## condition: "text.html.ruby, text.haml"
|
||||
# --
|
||||
<%= error_messages_for :${1:model} %>
|
||||
|
||||
<% form_for @${2:$1} do |f| -%>
|
||||
$0
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ff
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: form_for
|
||||
## condition: "text.html.ruby, text.haml"
|
||||
# --
|
||||
<% form_for @${1:model} do |f| -%>
|
||||
$0
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ist
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: image_submit_tag
|
||||
## condition: "text.html.ruby, text.haml"
|
||||
# --
|
||||
<%= image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1:$(file-name-sans-extension yas/text)}}"}${5:, :name => "${6:${1:$(file-name-sans-extension yas/text)}}"}${7:, :class => "${8:${1:$(file-name-sans-extension yas/text)}-button}"}${9:, :disabled => ${10:false}}}) %>
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: mp
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: map(&:sym_proc)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
map(&:${1:id})
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: st
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: submit_tag
|
||||
## condition: "text.html.ruby, text.haml"
|
||||
# --
|
||||
<%= submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"} %>
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fina
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: find(:all)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: finf
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: find(:first)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]})
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fini
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: find(id)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
find(${1:id})
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: fi
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: <%= Fixtures.identify(:symbol) %>
|
||||
## condition: "source.yaml"
|
||||
# --
|
||||
<%= Fixtures.identify(:${1:name}) %>$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: $L
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: $LABEL
|
||||
## condition: "source.yaml"
|
||||
# --
|
||||
\$LABEL
|
||||
@@ -1,11 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: cla
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Create functional test class
|
||||
## condition: "source.ruby"
|
||||
# --
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class ${1:Model}ControllerTest < ActionController::TestCase
|
||||
deft$0
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: art
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_redirected_to
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_redirected_to ${2::action => "${1:index}"}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: asre
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_response
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_response :${1:success}, @response.body$0
|
||||
@@ -1,8 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: asg
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert(var = assigns(:var))
|
||||
## condition: "source.ruby"
|
||||
# --
|
||||
assert(${1:var} = assigns(:$1), "Cannot find @$1")
|
||||
$0
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: artnpp
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_redirected_to (nested path plural)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:$2})}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: artnp
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_redirected_to (nested path)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:$12}, ${16:@}${17:$13})}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: artpp
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_redirected_to (path plural)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_redirected_to ${10:${2:model}s_path}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: artp
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_redirected_to (path)
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_redirected_to ${2:${12:model}_path(${13:@}${14:$12})}
|
||||
@@ -1,7 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: asrj
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_rjs
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_rjs :${1:replace}, ${2:"${3:dom id}"}
|
||||
@@ -1,9 +0,0 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: ass
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: assert_select
|
||||
## condition: "source.ruby.rails"
|
||||
# --
|
||||
assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do
|
||||
$0
|
||||
end}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user