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
# binding: RET
# condition: (yas/html-between-tag-pair-p)
# type: command
# --
$0
(save-excursion
(newline-and-indent))
(indent-according-to-mode)

View File

@ -134,9 +134,14 @@
(and (yas/rails-root)
(string-match "db/migrate/" default-directory)))
(defun yas/rails-activate-maybe
(when (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"
are recognized. Stolen from `rinari-mode' more or`' less."
(setq yas/rails-root-cache nil)
(when (yas/rails-root)
(set (make-local-variable 'yas/mode-symbol) 'rails-mode)))
(yas/rails-activate-maybe))
(add-hook 'find-file-hook 'yas/rails-activate-maybe)

View File

@ -2,6 +2,6 @@
# type: command
# contributor: Translated from TextMate Snippet
# name: Go to Controller
## binding: "~$@"
## 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"
# binding: C-c g c
# --
(call-interactively (find-file (concat (yas/rails-root) "/app/controllers")))

View File

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

View File

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

View File

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

View File

@ -2,6 +2,6 @@
# key: f.
# contributor: Translated from TextMate Snippet
# 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))}}"} %>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,6 +2,6 @@
# key: ffl
# contributor: Translated from TextMate Snippet
# 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))}}"} %>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,6 +7,5 @@
class ${1:`(yas/ruby-infer-class-name)`}
def initialize${2:$(if (string= yas/text "") "" "(")}${2:args}${2:$(if (string= yas/text "") "" ")")}
$0
end
end
end

View File

@ -3,4 +3,4 @@
# contributor: Translated from TextMate Snippet
# 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.