Last active
March 4, 2018 07:28
-
-
Save yalab/c51260a89d0b0544e7b8d4efb04bffdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun rb-strkeytosym (start end) | |
"ruby Hash key string to symbol" | |
(interactive "r") | |
(replace-regexp "\"\\([a-z_]+\\)\"=>" "\\1: " nil start end)) | |
(defun rb-htmlopttoerb (start end) | |
"html attreibute to erb option" | |
(interactive "r") | |
(replace-regexp " \\([a-z_]+\\)=" ", \\1: " nil start end)) | |
(defun strip-unused-html-attributes (start end) | |
"remove unused html attributes" | |
(interactive "r") | |
(replace-regexp "\\(value\\|style\\|type\\): \"[^\"]*\",?" "" nil start end)) | |
(defun rb-inputtoerb (start end) | |
"input tag to erb" | |
(interactive "r") | |
(funcall (lambda () | |
(replace-regexp | |
"<input\\([^>]+\\) ?name=\"\\([0-9a-z_]+\\)\"\\([^>]+\\)>" | |
"<%= f.text_field :\\2\\1\\3 %>" nil start end) | |
(call-interactively 'rb-htmlopttoerb) | |
(call-interactively 'strip-unused-html-attributes)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment