From d929f1922e64017ff6be2cb681c86c4957dfa456 Mon Sep 17 00:00:00 2001 From: jimi Date: Thu, 29 Jul 2010 20:11:34 -0500 Subject: [PATCH] Initial jquery, ruby, and eruby snippets - jquery ($ and drf) definitions - ruby (key => value) shortcuts - eruby basics: if, else, unless, for, image tags, link tags content_for, form_for, form elements, if flash, render partial --- ftplugin/eruby/eruby.xpt.vim | 91 ++++++++++++++++++++++++++++++ ftplugin/javascript/jquery.xpt.vim | 12 ++++ ftplugin/ruby/ruby.xpt.vim | 24 ++++++++ 3 files changed, 127 insertions(+) create mode 100644 ftplugin/eruby/eruby.xpt.vim create mode 100644 ftplugin/javascript/jquery.xpt.vim create mode 100644 ftplugin/ruby/ruby.xpt.vim diff --git a/ftplugin/eruby/eruby.xpt.vim b/ftplugin/eruby/eruby.xpt.vim new file mode 100644 index 0000000..5bc3b9d --- /dev/null +++ b/ftplugin/eruby/eruby.xpt.vim @@ -0,0 +1,91 @@ +" +" +XPTemplate priority=personal+ + +XPTvar $img_path 'images' + +XPT end " <% end -%> +<% end -%> + +XPT else " <% else -%> +<% else -%> +` `cursor^ + +XPT content_for synonym=cf|cof " <% content_for :head ... +<% content_for :`head^ do -%> +`cursor^ +`:end:^ + +XPT for " <% for item in items... +<% for `item^ in `@items^ -%> + `cursor^ +`:end:^ + +XPT if synonym=unless " <% $_xSnipName cond... +XSET action=Echo('') +XSET other=Echo('') +<% `$_xSnipName^ `cond^ -%> +` `action^ +``else..` +{{^<% else -%> +` `other^ +`}}^`:end:^ + +XPT ifl " <% if flash[... +<% if flash[:`notice^] -%> +
<%= flash[:`notice^] %>
+`:end:^ + +XPT it hidden " embed-able image tag +XSET image_path=$img_path/ +image_tag("`image_path^`image_file^"`, `opt?^) + +XPT image_tag synonym=imt " <%= image_tag... +<%= `:it:^ %> + +XPT link_to synonym=lt|lit " <%= link_to... +XSET link='`link_text^' +XSET target=Echo('') +<%= link_to `link^, `target^ %> + +XPT link_to_img synonym=ltim " <%= link_to image... +`:link_to({'link' : ':it:'}):^ + +XPT form_for synonym=ff " <% form_for @model do... +<% form_for `@obj^ do |`f^| -%> +` `cursor^ +`:end:^ + +XPT flabel " <%= f.label... +<%= `f^.label `:object^, '`label^' %> + +XPT ftxt " <%= f.text_field... +<%= `f^.text_field `:object^ %> + +XPT ftxa " <%= f.text_area... +<%= `f^.text_area `object^ %> + +XPT fhidden " <%= f.hidden_field... +<%= `f^.hidden_field `object^ %> + +XPT fpassword " <%= f.password_field... +<%= `f^.password_field `object^ %> + +XPT ferror " <%= f.error_messages... +<%= `f^.error_messages `object^ %> + +XPT fcheck " <%= f.check_box... +<%= `f^.check_box `object^ %> + +XPT fradio " <%= f.radio_button +<%= `f^.radio_button `object^ %> + +XPT ffile " <% f.file_field... +<%= `f^.file_field `:object^ %> + +XPT fsubmit " <%= f.submit... +<%= `f^.submit '`label^' %> + +XPT render_partial synonym=rp " <%= render :partial... +XSET name=Echo('') +<%= render :partial => "`name^" %> diff --git a/ftplugin/javascript/jquery.xpt.vim b/ftplugin/javascript/jquery.xpt.vim new file mode 100644 index 0000000..d6bc1a8 --- /dev/null +++ b/ftplugin/javascript/jquery.xpt.vim @@ -0,0 +1,12 @@ +" +" +XPTemplate priority=personal + +XPT $ " $(target) +$(`$SParg^`^`$SParg^) + +XPT drf " $(document).rea... +$(document).ready(function() { + `^ +}); + diff --git a/ftplugin/ruby/ruby.xpt.vim b/ftplugin/ruby/ruby.xpt.vim new file mode 100644 index 0000000..8c764c7 --- /dev/null +++ b/ftplugin/ruby/ruby.xpt.vim @@ -0,0 +1,24 @@ +" +" +XPTemplate priority=personal+ + +XPT key hidden " :key => val +XSET val=Echo('') +`$_xSnipName^ => `val^ + +XPT :cols synonym=:rows|:size|:maxsize|:null|:url +`:key:^ + +XPT :object synonym=:collection|:locals|:layout|:method +`:key:^ + +XPT :id synonym=:class|:alt|:title|:action|:controller +XSET str='`val^' +`:key({ 'val' : 'str' }):^ + +XPT :selected synonym=:multipart +XSET bool=true`^ +`:key({ 'val' : 'bool' }):^ + +XPT :html alias=key +XSET val={ `html^ }