tweaking rails and ruby snippets slightly

This commit is contained in:
capitaomorte 2010-03-29 18:15:56 +00:00
parent 2a88ccfaff
commit 485f34921b
23 changed files with 35 additions and 29 deletions

View File

@ -3,6 +3,8 @@
# name: Special: Return Inside Empty Open/Close Tags # name: Special: Return Inside Empty Open/Close Tags
# binding: RET # binding: RET
# condition: (yas/html-between-tag-pair-p) # condition: (yas/html-between-tag-pair-p)
# type: command
# -- # --
(save-excursion
$0 (newline-and-indent))
(indent-according-to-mode)

View File

@ -134,9 +134,14 @@
(and (yas/rails-root) (and (yas/rails-root)
(string-match "db/migrate/" default-directory))) (string-match "db/migrate/" default-directory)))
(defadvice cd (after yas/rails-on-cd-activate activate) (defun yas/rails-activate-maybe
"Set `yas/mode-symbol' to `rails-mode' so that rails snippets
are recognized"
(setq yas/rails-root-cache nil)
(when (yas/rails-root) (when (yas/rails-root)
(set (make-local-variable 'yas/mode-symbol) 'rails-mode))) (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 'find-file-hook 'yas/rails-activate-maybe)

View File

@ -2,6 +2,6 @@
# type: command # type: command
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: Go to Controller # name: Go to Controller
## binding: "~$@" # binding: C-c g c
## condition: "text.html.ruby, source.ruby.rails.embedded.html, meta.rails.helper, meta.rails.functional_test, source.js, source.css, source.yaml, meta.rails.model, meta.rails.unit_test, text.haml"
# -- # --
(call-interactively (find-file (concat (yas/rails-root) "/app/controllers")))

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.check_box (ffcb) # name: f.check_box (ffcb)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.check_box :${1:attribute} %> <%= f.check_box :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.file_field (ffff) # name: f.file_field (ffff)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.file_field :${1:attribute} %> <%= f.file_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.hidden_field (ffhf) # name: f.hidden_field (ffhf)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.hidden_field :${1:attribute} %> <%= f.hidden_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.label (ffl) # name: f.label (ffl)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.label :${1:attribute}${2:, "${3:${1:$(capitalize (replace-regexp-in-string "_" " " yas/text))}}"} %> <%= f.label :${1:attribute}${2:, "${3:${1:$(capitalize (replace-regexp-in-string "_" " " yas/text))}}"} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.password_field (ffpf) # name: f.password_field (ffpf)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.password_field :${1:attribute} %> <%= f.password_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.radio_box (ffrb) # name: f.radio_box (ffrb)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.radio_box :${1:attribute}, :${2:tag_value} %> <%= f.radio_box :${1:attribute}, :${2:tag_value} %>

View File

@ -1,7 +1,7 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.submit (ffs) # name: f.submit (ffs
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'} %> <%= f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.text_area (ffta) # name: f.text_area (ffta)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.text_area :${1:attribute} %> <%= f.text_area :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: f. # key: f.
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: f.text_field (fftf) # name: f.text_field (fftf)
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.text_field :${1:attribute} %> <%= f.text_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: ffcb # key: ffcb
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for check_box # name: form_for check_box
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.check_box :${1:attribute} %> <%= f.check_box :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: ffff # key: ffff
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for file_field # name: form_for file_field
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.file_field :${1:attribute} %> <%= f.file_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: ffhf # key: ffhf
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for hidden_field # name: form_for hidden_field
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.hidden_field :${1:attribute} %> <%= f.hidden_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: ffl # key: ffl
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for label # name: form_for label
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.label :${1:attribute}${2:, "${3:${1:$(capitalize (replace-regexp-in-string "_" " " yas/text))}}"} %> <%= f.label :${1:attribute}${2:, "${3:${1:$(capitalize (replace-regexp-in-string "_" " " yas/text))}}"} %>

View File

@ -2,6 +2,6 @@
# key: ffpf # key: ffpf
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for password_field # name: form_for password_field
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.password_field :${1:attribute} %> <%= f.password_field :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: ffrb # key: ffrb
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for radio_box # name: form_for radio_box
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.radio_box :${1:attribute}, :${2:tag_value} %> <%= f.radio_box :${1:attribute}, :${2:tag_value} %>

View File

@ -2,6 +2,6 @@
# key: ffs # key: ffs
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for submit # name: form_for submit
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'} %> <%= f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'} %>

View File

@ -2,6 +2,6 @@
# key: ffta # key: ffta
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for text_area # name: form_for text_area
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.text_area :${1:attribute} %> <%= f.text_area :${1:attribute} %>

View File

@ -2,6 +2,6 @@
# key: fftf # key: fftf
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: form_for text_field # name: form_for text_field
## condition: "text.html.ruby, text.haml" # condition: (yas/rails-view-p)
# -- # --
<%= f.text_field :${1:attribute} %> <%= f.text_field :${1:attribute} %>

View File

@ -9,4 +9,3 @@ class ${1:`(yas/ruby-infer-class-name)`}
$0 $0
end end
end end

View File

@ -3,4 +3,4 @@
# contributor: Translated from TextMate Snippet # contributor: Translated from TextMate Snippet
# name: Copyright Notice # name: Copyright Notice
# -- # --
(c) Copyright `(replace-regexp-in-string "[[:space:]]+$" "" (shell-command-to-string "date +%Y"))` `user-full-name`. All Rights Reserved. (c) Copyright `(replace-regexp-in-string "[ \n\t]+$" "" (shell-command-to-string "date +%Y"))` `user-full-name`. All Rights Reserved.