Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
1bfc94e060
2
AUTHORS
2
AUTHORS
@ -1,3 +1,4 @@
|
|||||||
|
Aaron Broder
|
||||||
Adam Folmert
|
Adam Folmert
|
||||||
Alberto Pose
|
Alberto Pose
|
||||||
Angel Alonso
|
Angel Alonso
|
||||||
@ -36,3 +37,4 @@ Povilas Balzaravičius Pawka
|
|||||||
Dmitry Dementev
|
Dmitry Dementev
|
||||||
Travis Holton
|
Travis Holton
|
||||||
Chrisyue
|
Chrisyue
|
||||||
|
Erik Westrup
|
||||||
|
33
README.md
33
README.md
@ -1,15 +1,35 @@
|
|||||||
|
IMPORTANT: comment on: [What about merging whith Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114)
|
||||||
|
|
||||||
Snipmate Snippets
|
Snipmate Snippets
|
||||||
=================
|
=================
|
||||||
|
|
||||||
This repository contains snippets files for various programming languages for
|
This repository contains snippets files for various programming languages.
|
||||||
the famous [snipMate][1] plugin for vim. This repository is
|
|
||||||
community-maintained and many people have contributed snippet files and other
|
It was originally written for the the famous [snipMate][1] plugin for vim.
|
||||||
improvements already.
|
However today there are at least 3 plugins which can make use of this snippet repository:
|
||||||
|
|
||||||
|
1) [snipMate][1]
|
||||||
|
|
||||||
|
2) [Shougo's neosnippet][5] has a compatible mode allowing
|
||||||
|
to reuse most snippets.
|
||||||
|
|
||||||
|
3) [ultisnip][6] (experimental, mind the branch snipmate-merge)
|
||||||
|
This code is subject to change. Take it as preview. That branch
|
||||||
|
has additional notes for Snipmate users. at the bottom.
|
||||||
|
In the long run ultisnip will have its own set of snippets, because it is
|
||||||
|
more powerful cause it supports nested snippets.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
It is community-maintained and many people have contributed snippet files and other
|
||||||
|
improvements already. Not sure whether it implements all features such as
|
||||||
|
guards - does anybody know?
|
||||||
|
|
||||||
[vim-snipmate][1] was originally started by [Michael Sanders][2] who has now
|
[vim-snipmate][1] was originally started by [Michael Sanders][2] who has now
|
||||||
unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a
|
unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a
|
||||||
[fork][4] of the project in hopes of improving the existing code base.
|
[fork][4] of the project in hopes of improving the existing code base.
|
||||||
|
|
||||||
|
|
||||||
Language maintainers
|
Language maintainers
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
@ -27,7 +47,8 @@ Contributing notes
|
|||||||
------------------
|
------------------
|
||||||
|
|
||||||
Until further work is done on `vim-snipmate`, please don't add folding markers
|
Until further work is done on `vim-snipmate`, please don't add folding markers
|
||||||
into snippets.
|
into snippets. `vim-snipmate` has some comments about how to patch all snippets
|
||||||
|
on the fly adding those.
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
-------
|
-------
|
||||||
@ -45,3 +66,5 @@ terms of the MIT license.
|
|||||||
[2]: http://github.com/msanders
|
[2]: http://github.com/msanders
|
||||||
[3]: http://github.com/garbas
|
[3]: http://github.com/garbas
|
||||||
[4]: http://github.com/garbas/vim-snipmate
|
[4]: http://github.com/garbas/vim-snipmate
|
||||||
|
[5]: https://github.com/Shougo/neosnippet
|
||||||
|
[6]: https://github.com/MarcWeber/UltiSnips/tree/snipmate-merge
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
"maintainer" : "honza @ github & others",
|
"maintainer" : "honza @ github & others",
|
||||||
"repository" : {"type": "git", "url": "git://github.com/honza/snipmate-snippets.git"},
|
"repository" : {"type": "git", "url": "git://github.com/honza/snipmate-snippets.git"},
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"snipmate": {}
|
|
||||||
},
|
},
|
||||||
"description" : "community driven set of snippets for snipmate"
|
"description" : "community driven set of snippets for snipmate"
|
||||||
}
|
}
|
||||||
|
@ -216,12 +216,25 @@ snippet APACHE
|
|||||||
|
|
||||||
${3}
|
${3}
|
||||||
snippet BEERWARE
|
snippet BEERWARE
|
||||||
${1:one line to give the program's name and a brief description}
|
${2:one line to give the program's name and a brief description}
|
||||||
Copyright `strftime("%Y")` ${2:copyright holder}
|
Copyright `strftime("%Y")` ${3:copyright holder}
|
||||||
|
|
||||||
Licensed under the "THE BEER-WARE LICENSE" (Revision 42):
|
Licensed under the "THE BEER-WARE LICENSE" (Revision 42):
|
||||||
${1:`g:snips_author`} wrote this file. As long as you retain this notice you
|
${1:`g:snips_author`} wrote this file. As long as you retain this notice you
|
||||||
can do whatever you want with this stuff. If we meet some day, and you think
|
can do whatever you want with this stuff. If we meet some day, and you think
|
||||||
this stuff is worth it, you can buy me a beer or coffee in return
|
this stuff is worth it, you can buy me a beer or coffee in return
|
||||||
|
|
||||||
${3}
|
${4}
|
||||||
|
|
||||||
|
snippet WTFPL
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
Version 2, December 2004
|
||||||
|
|
||||||
|
Copyright `strftime("%Y")` ${1:copyright holder}
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim or modified
|
||||||
|
copies of this license document, and changing it is allowed as long
|
||||||
|
as the name is changed.
|
||||||
|
|
||||||
|
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
@ -107,7 +107,7 @@ snippet try
|
|||||||
${3}
|
${3}
|
||||||
}
|
}
|
||||||
# For Loop (same as c.snippet)
|
# For Loop (same as c.snippet)
|
||||||
snippet for
|
snippet for for (..) {..}
|
||||||
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,45 @@
|
|||||||
# main()
|
## Main
|
||||||
|
# main
|
||||||
snippet main
|
snippet main
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
${1}
|
${1}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
# main(void)
|
||||||
snippet mainn
|
snippet mainn
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
${1}
|
${1}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
##
|
||||||
|
## Preprocessor
|
||||||
# #include <...>
|
# #include <...>
|
||||||
snippet inc
|
snippet inc
|
||||||
#include <${1:stdio}.h>${2}
|
#include <${1:stdio}.h>${2}
|
||||||
# #include "..."
|
# #include "..."
|
||||||
snippet Inc
|
snippet Inc
|
||||||
#include "${1:`Filename("$1.h")`}"${2}
|
#include "${1:`Filename("$1.h")`}"${2}
|
||||||
# #ifndef ... #define ... #endif
|
# ifndef...define...endif
|
||||||
snippet Def
|
snippet ndef
|
||||||
#ifndef $1
|
#ifndef $1
|
||||||
#define ${1:SYMBOL} ${2:value}
|
#define ${1:SYMBOL} ${2:value}
|
||||||
#endif${3}
|
#endif${3}
|
||||||
|
# define
|
||||||
snippet def
|
snippet def
|
||||||
#define
|
#define
|
||||||
|
# ifdef...endif
|
||||||
snippet ifdef
|
snippet ifdef
|
||||||
#ifdef ${1:FOO}
|
#ifdef ${1:FOO}
|
||||||
${2:#define }
|
${2:#define }
|
||||||
#endif
|
#endif${3}
|
||||||
|
# if
|
||||||
snippet #if
|
snippet #if
|
||||||
#if ${1:FOO}
|
#if ${1:FOO}
|
||||||
${2}
|
${2}
|
||||||
#endif
|
#endif
|
||||||
# Header Include-Guard
|
# header include guard
|
||||||
snippet once
|
snippet once
|
||||||
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
|
#ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
|
||||||
|
|
||||||
@ -41,73 +48,167 @@ snippet once
|
|||||||
${2}
|
${2}
|
||||||
|
|
||||||
#endif /* end of include guard: $1 */
|
#endif /* end of include guard: $1 */
|
||||||
# If Condition
|
##
|
||||||
|
## Control Statements
|
||||||
|
# if
|
||||||
snippet if
|
snippet if
|
||||||
if (${1:/* condition */}) {
|
if (${1:/* condition */}) {
|
||||||
${2:/* code */}
|
${2:/* code */}
|
||||||
}
|
}${3}
|
||||||
|
# else
|
||||||
snippet el
|
snippet el
|
||||||
else {
|
else {
|
||||||
${1}
|
${1}
|
||||||
}
|
}${3}
|
||||||
# Ternary conditional
|
# else if
|
||||||
|
snippet elif
|
||||||
|
else if (${1:/* condition */}) {
|
||||||
|
${2:/* code */}
|
||||||
|
}${3}
|
||||||
|
# ternary
|
||||||
snippet t
|
snippet t
|
||||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||||
# Do While Loop
|
# switch
|
||||||
snippet do
|
snippet switch
|
||||||
do {
|
switch (${1:/* variable */}) {
|
||||||
${2:/* code */}
|
case ${2:/* variable case */}:
|
||||||
} while (${1:/* condition */});
|
${3}
|
||||||
# While Loop
|
${4:break;}${5}
|
||||||
snippet wh
|
default:
|
||||||
while (${1:/* condition */}) {
|
${6}
|
||||||
${2:/* code */}
|
}${7}
|
||||||
}
|
# switch without default
|
||||||
# For Loop
|
snippet switchndef
|
||||||
|
switch (${1:/* variable */}) {
|
||||||
|
case ${2:/* variable case */}:
|
||||||
|
${3}
|
||||||
|
${4:break;}${5}
|
||||||
|
}${6}
|
||||||
|
# case
|
||||||
|
snippet case
|
||||||
|
case ${1:/* variable case */}:
|
||||||
|
${2}
|
||||||
|
${3:break;}${4}
|
||||||
|
##
|
||||||
|
## Loops
|
||||||
|
# for
|
||||||
snippet for
|
snippet for
|
||||||
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}${5}
|
||||||
# Custom For Loop
|
# for (custom)
|
||||||
snippet forr
|
snippet forr
|
||||||
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
|
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
|
||||||
${5:/* code */}
|
${5:/* code */}
|
||||||
}
|
}${6}
|
||||||
# Function
|
# while
|
||||||
|
snippet wh
|
||||||
|
while (${1:/* condition */}) {
|
||||||
|
${2:/* code */}
|
||||||
|
}${3}
|
||||||
|
# do... while
|
||||||
|
snippet do
|
||||||
|
do {
|
||||||
|
${2:/* code */}
|
||||||
|
} while (${1:/* condition */});${3}
|
||||||
|
##
|
||||||
|
## Functions
|
||||||
|
# function definition
|
||||||
snippet fun
|
snippet fun
|
||||||
${1:void} ${2:function_name}(${3})
|
${1:void} ${2:function_name}(${3})
|
||||||
{
|
{
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}${5}
|
||||||
# Function Declaration
|
# function declaration
|
||||||
snippet fund
|
snippet fund
|
||||||
${1:void} ${2:function_name}(${3});${4}
|
${1:void} ${2:function_name}(${3});${4}
|
||||||
# Typedef
|
##
|
||||||
|
## Types
|
||||||
|
# typedef
|
||||||
snippet td
|
snippet td
|
||||||
typedef ${1:int} ${2:MyCustomType};${3}
|
typedef ${1:int} ${2:MyCustomType};${3}
|
||||||
# Struct
|
# struct
|
||||||
snippet st
|
snippet st
|
||||||
struct ${1:`Filename('$1_t', 'name')`} {
|
struct ${1:`Filename('$1_t', 'name')`} {
|
||||||
${2:/* data */}
|
${2:/* data */}
|
||||||
}${3: /* optional variable list */};${4}
|
}${3: /* optional variable list */};${4}
|
||||||
# Typedef struct
|
# typedef struct
|
||||||
snippet tds
|
snippet tds
|
||||||
typedef struct ${2:_$1 }{
|
typedef struct ${2:_$1 }{
|
||||||
${3:/* data */}
|
${3:/* data */}
|
||||||
} ${1:`Filename('$1_t', 'name')`};
|
} ${1:`Filename('$1_t', 'name')`};${4}
|
||||||
# Typdef enum
|
# typedef enum
|
||||||
snippet tde
|
snippet tde
|
||||||
typedef enum {
|
typedef enum {
|
||||||
${1:/* data */}
|
${1:/* data */}
|
||||||
} ${2:foo};
|
} ${2:foo};${3}
|
||||||
|
##
|
||||||
|
## Input/Output
|
||||||
# printf
|
# printf
|
||||||
# unfortunately version this isn't as nice as TextMates's, given the lack of a
|
|
||||||
# dynamic `...`
|
|
||||||
snippet pr
|
snippet pr
|
||||||
printf("${1:%s}\n"${2});${3}
|
printf("${1:%s}\n"${2});${3}
|
||||||
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
# fprintf (again, this isn't as nice as TextMate's version, but it works)
|
||||||
snippet fpr
|
snippet fpr
|
||||||
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
|
||||||
|
# getopt
|
||||||
|
snippet getopt
|
||||||
|
int choice;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
static struct option long_options[] =
|
||||||
|
{
|
||||||
|
/* Use flags like so:
|
||||||
|
{"verbose", no_argument, &verbose_flag, 'V'}*/
|
||||||
|
/* Argument styles: no_argument, required_argument, optional_argument */
|
||||||
|
{"version", no_argument, 0, 'v'},
|
||||||
|
{"help", no_argument, 0, 'h'},
|
||||||
|
${1}
|
||||||
|
{0,0,0,0}
|
||||||
|
};
|
||||||
|
|
||||||
|
int option_index = 0;
|
||||||
|
|
||||||
|
/* Argument parameters:
|
||||||
|
no_argument: " "
|
||||||
|
required_argument: ":"
|
||||||
|
optional_argument: "::" */
|
||||||
|
|
||||||
|
choice = getopt_long( argc, argv, "vh",
|
||||||
|
long_options, &option_index);
|
||||||
|
|
||||||
|
if (choice == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch( choice )
|
||||||
|
{
|
||||||
|
case 'v':
|
||||||
|
${2}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
${3}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
/* getopt_long will have already printed an error */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* Not sure how to get here... */
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Deal with non-option arguments here */
|
||||||
|
if ( optind < argc )
|
||||||
|
{
|
||||||
|
while ( optind < argc )
|
||||||
|
{
|
||||||
|
${4}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
##
|
||||||
|
## Miscellaneous
|
||||||
# This is kind of convenient
|
# This is kind of convenient
|
||||||
snippet .
|
snippet .
|
||||||
[${1}]${2}
|
[${1}]${2}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
# Closure loop
|
||||||
|
snippet forindo
|
||||||
|
for ${1:name} in ${2:array}
|
||||||
|
do ($1) ->
|
||||||
|
${3:// body}
|
||||||
# Array comprehension
|
# Array comprehension
|
||||||
snippet fora
|
snippet fora
|
||||||
for ${1:name} in ${2:array}
|
for ${1:name} in ${2:array}
|
||||||
@ -85,3 +90,6 @@ snippet try
|
|||||||
# Require
|
# Require
|
||||||
snippet req
|
snippet req
|
||||||
${2:$1} = require '${1:sys}'${3}
|
${2:$1} = require '${1:sys}'${3}
|
||||||
|
# Export
|
||||||
|
snippet exp
|
||||||
|
${1:root} = exports ? this
|
||||||
|
@ -1,29 +1,73 @@
|
|||||||
# Read File Into Vector
|
## STL Collections
|
||||||
snippet readfile
|
# std::array
|
||||||
std::vector<char> v;
|
snippet array
|
||||||
if (FILE *${2:fp} = fopen(${1:"filename"}, "r")) {
|
std::array<${1:T}, ${2:N}> ${3};${4}
|
||||||
char buf[1024];
|
|
||||||
while (size_t len = fread(buf, 1, sizeof(buf), $2))
|
|
||||||
v.insert(v.end(), buf, buf + len);
|
|
||||||
fclose($2);
|
|
||||||
}${3}
|
|
||||||
|
|
||||||
# std::map
|
|
||||||
snippet map
|
|
||||||
std::map<${1:key}, ${2:value}> ${3};
|
|
||||||
|
|
||||||
# std::vector
|
# std::vector
|
||||||
snippet vector
|
snippet vector
|
||||||
std::vector<${1:char}> ${2};
|
std::vector<${1:T}> ${2};${3}
|
||||||
|
# std::deque
|
||||||
# Namespace
|
snippet deque
|
||||||
snippet ns
|
std::deque<${1:T}> ${2};${3}
|
||||||
namespace ${1:`Filename('', 'my')`} {
|
# std::forward_list
|
||||||
${2}
|
snippet flist
|
||||||
} /* namespace $1 */
|
std::forward_list<${1:T}> ${2};${3}
|
||||||
|
# std::list
|
||||||
# Class
|
snippet list
|
||||||
snippet class
|
std::list<${1:T}> ${2};${3}
|
||||||
|
# std::set
|
||||||
|
snippet set
|
||||||
|
std::set<${1:T}> ${2};${3}
|
||||||
|
# std::map
|
||||||
|
snippet map
|
||||||
|
std::map<${1:Key}, ${2:T}> ${3};${4}
|
||||||
|
# std::multiset
|
||||||
|
snippet mset
|
||||||
|
std::multiset<${1:T}> ${2};${3}
|
||||||
|
# std::multimap
|
||||||
|
snippet mmap
|
||||||
|
std::multimap<${1:Key}, ${2:T}> ${3};${4}
|
||||||
|
# std::unordered_set
|
||||||
|
snippet uset
|
||||||
|
std::unordered_set<${1:T}> ${2};${3}
|
||||||
|
# std::unordered_map
|
||||||
|
snippet umap
|
||||||
|
std::unordered_map<${1:Key}, ${2:T}> ${3};${4}
|
||||||
|
# std::unordered_multiset
|
||||||
|
snippet umset
|
||||||
|
std::unordered_multiset<${1:T}> ${2};${3}
|
||||||
|
# std::unordered_multimap
|
||||||
|
snippet ummap
|
||||||
|
std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4}
|
||||||
|
# std::stack
|
||||||
|
snippet stack
|
||||||
|
std::stack<${1:T}> ${2};${3}
|
||||||
|
# std::queue
|
||||||
|
snippet queue
|
||||||
|
std::queue<${1:T}> ${2};${3}
|
||||||
|
# std::priority_queue
|
||||||
|
snippet pqueue
|
||||||
|
std::priority_queue<${1:T}> ${2};${3}
|
||||||
|
##
|
||||||
|
## Access Modifiers
|
||||||
|
# private
|
||||||
|
snippet pri
|
||||||
|
private
|
||||||
|
# protected
|
||||||
|
snippet pro
|
||||||
|
protected
|
||||||
|
# public
|
||||||
|
snippet pub
|
||||||
|
public
|
||||||
|
# friend
|
||||||
|
snippet fr
|
||||||
|
friend
|
||||||
|
# mutable
|
||||||
|
snippet mu
|
||||||
|
mutable
|
||||||
|
##
|
||||||
|
## Class
|
||||||
|
# class
|
||||||
|
snippet cl
|
||||||
class ${1:`Filename('$1', 'name')`}
|
class ${1:`Filename('$1', 'name')`}
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -33,34 +77,55 @@ snippet class
|
|||||||
private:
|
private:
|
||||||
${3:/* data */}
|
${3:/* data */}
|
||||||
};
|
};
|
||||||
|
# member function implementation
|
||||||
|
snippet mfun
|
||||||
|
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
|
||||||
|
${5:/* code */}
|
||||||
|
}
|
||||||
|
# namespace
|
||||||
|
snippet ns
|
||||||
|
namespace ${1:`Filename('', 'my')`} {
|
||||||
|
${2}
|
||||||
|
} /* namespace $1 */
|
||||||
|
##
|
||||||
|
## Input/Output
|
||||||
|
# std::cout
|
||||||
|
snippet cout
|
||||||
|
std::cout << ${1} << std::endl;${2}
|
||||||
|
# std::cin
|
||||||
|
snippet cin
|
||||||
|
std::cin >> ${1};${2}
|
||||||
|
##
|
||||||
|
## Iteration
|
||||||
|
# for i
|
||||||
snippet fori
|
snippet fori
|
||||||
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
||||||
${4:/* code */}
|
${4:/* code */}
|
||||||
}
|
}${5}
|
||||||
|
|
||||||
|
# foreach
|
||||||
|
snippet fore
|
||||||
|
for (${1:auto} ${2:i} : ${3:container}) {
|
||||||
|
${4:/* code */}
|
||||||
|
}${5}
|
||||||
|
# iterator
|
||||||
|
snippet iter
|
||||||
|
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
|
||||||
|
${6}
|
||||||
|
}${7}
|
||||||
|
|
||||||
# auto iterator
|
# auto iterator
|
||||||
snippet itera
|
snippet itera
|
||||||
for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {
|
for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {
|
||||||
${2:std::cout << *$1 << std::endl;}
|
${2:std::cout << *$1 << std::endl;}
|
||||||
}
|
}${3}
|
||||||
|
##
|
||||||
# iterator
|
## Lambdas
|
||||||
snippet iter
|
# lamda (one line)
|
||||||
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
|
snippet ld
|
||||||
${6}
|
[${1}](${2}){${3:/* code */}}${4}
|
||||||
}
|
# lambda (multi-line)
|
||||||
|
snippet lld
|
||||||
# member function implementations
|
[${1}](${2}){
|
||||||
snippet mfun
|
${3:/* code */}
|
||||||
${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
|
}${4}
|
||||||
${5:return};
|
|
||||||
}
|
|
||||||
snippet scout
|
|
||||||
std::cout << ${1} << std::endl;
|
|
||||||
snippet cout
|
|
||||||
cout << ${1} << endl;
|
|
||||||
snippet scin
|
|
||||||
std::cin >> ${1};
|
|
||||||
snippet cin
|
|
||||||
cin >> ${1};
|
|
||||||
|
@ -81,10 +81,6 @@ snippet fields
|
|||||||
<% fields_for :${1:model}, @$1 do |${2:f}| %>
|
<% fields_for :${1:model}, @$1 do |${2:f}| %>
|
||||||
${3}
|
${3}
|
||||||
<% end %>
|
<% end %>
|
||||||
snippet ff
|
|
||||||
<%= form_for @${1:model} do |f| %>
|
|
||||||
${2}
|
|
||||||
<% end %>
|
|
||||||
snippet i18
|
snippet i18
|
||||||
I18n.t('${1:type.key}')${2}
|
I18n.t('${1:type.key}')${2}
|
||||||
snippet it
|
snippet it
|
||||||
|
@ -353,11 +353,11 @@ snippet footer
|
|||||||
${1}
|
${1}
|
||||||
</footer>
|
</footer>
|
||||||
snippet footer.
|
snippet footer.
|
||||||
<footer class="${1}>
|
<footer class="${1}">
|
||||||
${2}
|
${2}
|
||||||
</footer>
|
</footer>
|
||||||
snippet footer#
|
snippet footer#
|
||||||
<footer id="${1}>
|
<footer id="${1}">
|
||||||
${2}
|
${2}
|
||||||
</footer>
|
</footer>
|
||||||
snippet form
|
snippet form
|
||||||
@ -445,6 +445,18 @@ snippet xhtml
|
|||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
${1}
|
${1}
|
||||||
</html>
|
</html>
|
||||||
|
snippet html5
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||||
|
<title>${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`}</title>
|
||||||
|
${2:meta}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
${3:body}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
snippet i
|
snippet i
|
||||||
<i>${1}</i>
|
<i>${1}</i>
|
||||||
snippet iframe
|
snippet iframe
|
||||||
|
@ -140,7 +140,7 @@ snippet /**
|
|||||||
* ${1}
|
* ${1}
|
||||||
*/
|
*/
|
||||||
snippet @au
|
snippet @au
|
||||||
@author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")`
|
@author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5 | cut -d \",\" -f1")`
|
||||||
snippet @br
|
snippet @br
|
||||||
@brief ${1:Description}
|
@brief ${1:Description}
|
||||||
snippet @fi
|
snippet @fi
|
||||||
@ -176,9 +176,9 @@ snippet main
|
|||||||
##
|
##
|
||||||
## Print Methods
|
## Print Methods
|
||||||
snippet print
|
snippet print
|
||||||
System.out.print("${1:Message");
|
System.out.print("${1:Message}");
|
||||||
snippet printf
|
snippet printf
|
||||||
System.out.printf("${1:Message", ${2:args});
|
System.out.printf("${1:Message}", ${2:args});
|
||||||
snippet println
|
snippet println
|
||||||
System.out.println(${1});
|
System.out.println(${1});
|
||||||
##
|
##
|
||||||
|
@ -11,12 +11,12 @@ snippet fun
|
|||||||
}
|
}
|
||||||
# Anonymous Function
|
# Anonymous Function
|
||||||
snippet f
|
snippet f
|
||||||
function(${1}) {
|
function (${1}) {
|
||||||
${3}
|
${3}
|
||||||
}${2:;}
|
}${2:;}
|
||||||
# Immediate function
|
# Immediate function
|
||||||
snippet (f
|
snippet (f
|
||||||
(function(${1}) {
|
(function (${1}) {
|
||||||
${3:/* code */}
|
${3:/* code */}
|
||||||
}(${2}));
|
}(${2}));
|
||||||
# if
|
# if
|
||||||
@ -32,11 +32,11 @@ snippet ife
|
|||||||
${3}
|
${3}
|
||||||
}
|
}
|
||||||
# tertiary conditional
|
# tertiary conditional
|
||||||
snippet t
|
snippet ter
|
||||||
${1:/* condition */} ? ${2:a} : ${3:b}
|
${1:/* condition */} ? ${2:a} : ${3:b}
|
||||||
# switch
|
# switch
|
||||||
snippet switch
|
snippet switch
|
||||||
switch(${1:expression}) {
|
switch (${1:expression}) {
|
||||||
case '${3:case}':
|
case '${3:case}':
|
||||||
${4:// code}
|
${4:// code}
|
||||||
break;
|
break;
|
||||||
@ -69,7 +69,7 @@ snippet wh
|
|||||||
snippet try
|
snippet try
|
||||||
try {
|
try {
|
||||||
${1:/* code */}
|
${1:/* code */}
|
||||||
} catch(${2:e}) {
|
} catch (${2:e}) {
|
||||||
${3:/* handle error */}
|
${3:/* handle error */}
|
||||||
}
|
}
|
||||||
# do...while
|
# do...while
|
||||||
@ -79,12 +79,12 @@ snippet do
|
|||||||
} while (${1:/* condition */});
|
} while (${1:/* condition */});
|
||||||
# Object Method
|
# Object Method
|
||||||
snippet :f
|
snippet :f
|
||||||
${1:method_name}: function(${2:attribute}) {
|
${1:method_name}: function (${2:attribute}) {
|
||||||
${4}
|
${4}
|
||||||
}${3:,}
|
}${3:,}
|
||||||
# setTimeout function
|
# setTimeout function
|
||||||
snippet timeout
|
snippet timeout
|
||||||
setTimeout(function() {${3}}${2}, ${1:10});
|
setTimeout(function () {${3}}${2}, ${1:10});
|
||||||
# Get Elements
|
# Get Elements
|
||||||
snippet get
|
snippet get
|
||||||
getElementsBy${1:TagName}('${2}')${3}
|
getElementsBy${1:TagName}('${2}')${3}
|
||||||
|
5
snippets/ledger.snippets
Normal file
5
snippets/ledger.snippets
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Ledger <http://ledger-cli.org/>
|
||||||
|
snippet ent
|
||||||
|
`strftime("%Y/%m/%d")` ${1:transaction}
|
||||||
|
${2:account} ${3:value}
|
||||||
|
${4:account}
|
@ -79,48 +79,54 @@ snippet for
|
|||||||
snippet fore
|
snippet fore
|
||||||
${1:expression} foreach @${2:array};${3}
|
${1:expression} foreach @${2:array};${3}
|
||||||
# Package
|
# Package
|
||||||
snippet cl
|
snippet package
|
||||||
package ${1:ClassName};
|
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`};
|
||||||
|
|
||||||
use base qw(${2:ParentClass});
|
${2}
|
||||||
|
|
||||||
sub new {
|
1;
|
||||||
my $class = shift;
|
|
||||||
$class = ref $class if ref $class;
|
|
||||||
my $self = bless {}, $class;
|
|
||||||
$self;
|
|
||||||
}
|
|
||||||
|
|
||||||
1;${3}
|
__END__
|
||||||
|
# Package syntax perl >= 5.14
|
||||||
|
snippet packagev514
|
||||||
|
package ${1:`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
|
||||||
|
|
||||||
|
${3}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
#moose
|
||||||
|
snippet moose
|
||||||
|
use Moose;
|
||||||
|
use namespace::autoclean;
|
||||||
|
${1:#}BEGIN {extends '${2:ParentClass}'};
|
||||||
|
|
||||||
|
${3}
|
||||||
|
# parent
|
||||||
|
snippet parent
|
||||||
|
use parent qw(${1:Parent Class});
|
||||||
# Read File
|
# Read File
|
||||||
snippet slurp
|
snippet slurp
|
||||||
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
|
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
|
||||||
${3}
|
${3}
|
||||||
|
|
||||||
|
|
||||||
# strict warnings
|
# strict warnings
|
||||||
snippet strwar
|
snippet strwar
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
# older versioning with perlcritic bypass
|
||||||
|
|
||||||
# standard versioning with perlcritic bypass
|
|
||||||
snippet vers
|
snippet vers
|
||||||
## no critic
|
## no critic
|
||||||
our $VERSION = '${1:version}';
|
our $VERSION = '${1:version}';
|
||||||
eval $VERSION;
|
eval $VERSION;
|
||||||
## use critic
|
## use critic
|
||||||
|
|
||||||
|
|
||||||
# new 'switch' like feature
|
# new 'switch' like feature
|
||||||
snippet switch
|
snippet switch
|
||||||
use feature 'switch';
|
use feature 'switch';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Anonymous subroutine
|
# Anonymous subroutine
|
||||||
snippet asub
|
snippet asub
|
||||||
sub {
|
sub {
|
||||||
${1:# body }
|
${1:# body }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,19 +139,19 @@ snippet begin
|
|||||||
}
|
}
|
||||||
|
|
||||||
# call package function with some parameter
|
# call package function with some parameter
|
||||||
snippet pkgmv
|
snippet pkgmv
|
||||||
__PACKAGE__->${1:package_method}(${2:var})
|
__PACKAGE__->${1:package_method}(${2:var})
|
||||||
|
|
||||||
# call package function without a parameter
|
# call package function without a parameter
|
||||||
snippet pkgm
|
snippet pkgm
|
||||||
__PACKAGE__->${1:package_method}()
|
__PACKAGE__->${1:package_method}()
|
||||||
|
|
||||||
# call package "get_" function without a parameter
|
# call package "get_" function without a parameter
|
||||||
snippet pkget
|
snippet pkget
|
||||||
__PACKAGE__->get_${1:package_method}()
|
__PACKAGE__->get_${1:package_method}()
|
||||||
|
|
||||||
# call package function with a parameter
|
# call package function with a parameter
|
||||||
snippet pkgetv
|
snippet pkgetv
|
||||||
__PACKAGE__->get_${1:package_method}(${2:var})
|
__PACKAGE__->get_${1:package_method}(${2:var})
|
||||||
|
|
||||||
# complex regex
|
# complex regex
|
||||||
@ -160,10 +166,10 @@ snippet qr/
|
|||||||
|
|
||||||
#given
|
#given
|
||||||
snippet given
|
snippet given
|
||||||
given ($${1:var}) {
|
given ($${1:var}) {
|
||||||
${2:# cases}
|
${2:# cases}
|
||||||
${3:# default}
|
${3:# default}
|
||||||
}
|
}
|
||||||
|
|
||||||
# switch-like case
|
# switch-like case
|
||||||
snippet when
|
snippet when
|
||||||
@ -176,7 +182,6 @@ snippet hslice
|
|||||||
@{ ${1:hash} }{ ${2:array} }
|
@{ ${1:hash} }{ ${2:array} }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# map
|
# map
|
||||||
snippet map
|
snippet map
|
||||||
map { ${2: body } } ${1: @array } ;
|
map { ${2: body } } ${1: @array } ;
|
||||||
@ -190,7 +195,7 @@ snippet ppod
|
|||||||
${1:ClassName} - ${2:ShortDesc}
|
${1:ClassName} - ${2:ShortDesc}
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
use $1;
|
use $1;
|
||||||
|
|
||||||
${3:# synopsis...}
|
${3:# synopsis...}
|
||||||
@ -202,7 +207,7 @@ snippet ppod
|
|||||||
|
|
||||||
=head1 INTERFACE
|
=head1 INTERFACE
|
||||||
|
|
||||||
|
|
||||||
=head1 DEPENDENCIES
|
=head1 DEPENDENCIES
|
||||||
|
|
||||||
|
|
||||||
@ -223,8 +228,17 @@ snippet psubi
|
|||||||
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
# inline documented subroutine
|
||||||
|
snippet subpod
|
||||||
|
=head2 $1
|
||||||
|
|
||||||
|
Summary of $1
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub ${1:subroutine_name} {
|
||||||
|
${2:# body...}
|
||||||
|
}
|
||||||
# Subroutine signature
|
# Subroutine signature
|
||||||
snippet parg
|
snippet parg
|
||||||
=over 2
|
=over 2
|
||||||
@ -232,7 +246,7 @@ snippet parg
|
|||||||
=item
|
=item
|
||||||
Arguments
|
Arguments
|
||||||
|
|
||||||
|
|
||||||
=over 3
|
=over 3
|
||||||
|
|
||||||
=item
|
=item
|
||||||
@ -255,47 +269,21 @@ snippet parg
|
|||||||
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Moose package
|
|
||||||
snippet moosecl
|
|
||||||
package ${1:ClassName};
|
|
||||||
|
|
||||||
use Moose;
|
|
||||||
#extends '${2:# ParentClass}';
|
|
||||||
|
|
||||||
${6:# body of class}
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
|
|
||||||
__END__
|
|
||||||
|
|
||||||
=head1 NAME
|
|
||||||
|
|
||||||
$1 - ${3:ShortDesc}
|
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
|
||||||
|
|
||||||
${4:# synopsis...}
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
|
||||||
|
|
||||||
${5:# longer description...}
|
|
||||||
|
|
||||||
|
|
||||||
# Moose has
|
# Moose has
|
||||||
snippet has
|
snippet has
|
||||||
has ${1:attribute} => (
|
has ${1:attribute} => (
|
||||||
is => '${2:ro|rw}',
|
is => '${2:ro|rw}',
|
||||||
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
|
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
|
||||||
default => ${4:defaultvalue}
|
default => sub {
|
||||||
,${5:# other attributes}
|
${4:defaultvalue}
|
||||||
|
},
|
||||||
|
${5:# other attributes}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -303,14 +291,14 @@ snippet has
|
|||||||
snippet override
|
snippet override
|
||||||
override ${1:attribute} => sub {
|
override ${1:attribute} => sub {
|
||||||
${2:# my $self = shift;};
|
${2:# my $self = shift;};
|
||||||
${3:# my ($self,$args) = @_;};
|
${3:# my ($self, $args) = @_;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# use test classes
|
# use test classes
|
||||||
snippet tuse
|
snippet tuse
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use Test::Deep ();
|
use Test::Deep; # (); # uncomment to stop prototype errors
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
# local test lib
|
# local test lib
|
||||||
@ -331,7 +319,7 @@ snippet tsub
|
|||||||
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
${4:# body}
|
${4:# body}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test::Routine-style test
|
# Test::Routine-style test
|
||||||
@ -347,6 +335,7 @@ snippet tprep
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
${4:# body}
|
${4:# body}
|
||||||
}
|
}
|
||||||
|
|
||||||
# cause failures to print stack trace
|
# cause failures to print stack trace
|
||||||
snippet debug_trace
|
snippet debug_trace
|
||||||
use Carp; # 'verbose';
|
use Carp; # 'verbose';
|
||||||
|
109
snippets/plsql.snippets
Normal file
109
snippets/plsql.snippets
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
# create package spec
|
||||||
|
snippet ps
|
||||||
|
create or replace package ${1:name}
|
||||||
|
as
|
||||||
|
${2:-- spec}
|
||||||
|
end; -- end of package spec $1
|
||||||
|
# create package body
|
||||||
|
snippet pb
|
||||||
|
create or replace package body ${1:name}
|
||||||
|
as
|
||||||
|
${2:-- body}
|
||||||
|
end; -- end of package body $1;
|
||||||
|
# package procedure spec
|
||||||
|
snippet pps
|
||||||
|
procedure ${1:name}(${2:args});
|
||||||
|
# package procedure body
|
||||||
|
snippet ppb
|
||||||
|
procedure ${1:name}(${2:args})
|
||||||
|
as
|
||||||
|
begin
|
||||||
|
${3:-- body}
|
||||||
|
end $2;
|
||||||
|
# package function spec
|
||||||
|
snippet pfs
|
||||||
|
function ${1:name}(${2:args})
|
||||||
|
return ${3:type};
|
||||||
|
# package function body
|
||||||
|
snippet pfb
|
||||||
|
function ${1:name}(${2:args})
|
||||||
|
return ${3:type}
|
||||||
|
as
|
||||||
|
l_res $3;
|
||||||
|
begin
|
||||||
|
${4:-- body};
|
||||||
|
return l_res;
|
||||||
|
end $1;
|
||||||
|
# snow errors
|
||||||
|
snippet err
|
||||||
|
show errors;
|
||||||
|
# proc/func in parameter
|
||||||
|
snippet p
|
||||||
|
${1:name} ${2:in} ${3:type} ${4: := null}
|
||||||
|
# package type: record
|
||||||
|
snippet tr
|
||||||
|
type tr_${1:name} is record (${2:/* columns */});
|
||||||
|
# package type: nested table
|
||||||
|
snippet tt
|
||||||
|
type tt_${1:name} is table of tr_${2:name};
|
||||||
|
# package type: indexed table
|
||||||
|
snippet tti
|
||||||
|
type tt_${1:name} is table of tr_${2:name} index by binary_integer;
|
||||||
|
# proc/func comment
|
||||||
|
snippet doc
|
||||||
|
/*
|
||||||
|
* ${1: comment ...}
|
||||||
|
*/
|
||||||
|
# plsql block
|
||||||
|
snippet beg
|
||||||
|
begin
|
||||||
|
${1}
|
||||||
|
end;
|
||||||
|
# plsql block with declare part
|
||||||
|
snippet dec
|
||||||
|
declare
|
||||||
|
${1}
|
||||||
|
begin
|
||||||
|
${2}
|
||||||
|
end;
|
||||||
|
# return pipe row
|
||||||
|
snippet rpipe
|
||||||
|
for ${1:i} in 1 .. ${2:l_res}.count loop
|
||||||
|
pipe row( $2($1) );
|
||||||
|
end loop;
|
||||||
|
return;
|
||||||
|
# bulk collect
|
||||||
|
snippet bc
|
||||||
|
bulk collect into ${1}
|
||||||
|
# local variable
|
||||||
|
snippet l
|
||||||
|
l_${1} ${2:number};
|
||||||
|
# output
|
||||||
|
snippet log
|
||||||
|
dbms_output.put_line('${1}');
|
||||||
|
# for loop
|
||||||
|
snippet for
|
||||||
|
for ${1:i} in ${2:1}..${3:42} loop
|
||||||
|
${3}
|
||||||
|
end loop;
|
||||||
|
# for loop with select
|
||||||
|
snippet fors
|
||||||
|
for ${1:rec} in (${2: select}) loop
|
||||||
|
${3}
|
||||||
|
end loop;
|
||||||
|
# for loop with collection
|
||||||
|
snippet forc
|
||||||
|
for ${1:i} in ${2:l_var}.first .. $2.last loop
|
||||||
|
${3: -- dbms_output.put_line($2($1)); }
|
||||||
|
end loop;
|
||||||
|
# if
|
||||||
|
snippet if
|
||||||
|
if ${1} then
|
||||||
|
${2}
|
||||||
|
end if;
|
||||||
|
snippet ife
|
||||||
|
if ${1} then
|
||||||
|
${2}
|
||||||
|
else
|
||||||
|
${3}
|
||||||
|
end if;
|
@ -13,16 +13,16 @@ snippet docs
|
|||||||
'''
|
'''
|
||||||
snippet wh
|
snippet wh
|
||||||
while ${1:condition}:
|
while ${1:condition}:
|
||||||
${2:# code...}
|
${2:# TODO: write code...}
|
||||||
# dowh - does the same as do...while in other languages
|
# dowh - does the same as do...while in other languages
|
||||||
snippet dowh
|
snippet dowh
|
||||||
while True:
|
while True:
|
||||||
${1:# code...}
|
${1:# TODO: write code...}
|
||||||
if ${2:condition}:
|
if ${2:condition}:
|
||||||
break
|
break
|
||||||
snippet with
|
snippet with
|
||||||
with ${1:expr} as ${2:var}:
|
with ${1:expr} as ${2:var}:
|
||||||
${3:# code...}
|
${3:# TODO: write code...}
|
||||||
# New Class
|
# New Class
|
||||||
snippet cl
|
snippet cl
|
||||||
class ${1:ClassName}(${2:object}):
|
class ${1:ClassName}(${2:object}):
|
||||||
@ -35,14 +35,14 @@ snippet cl
|
|||||||
snippet def
|
snippet def
|
||||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||||
"""${3:docstring for $1}"""
|
"""${3:docstring for $1}"""
|
||||||
${4:pass}
|
${4:# TODO: write code...}
|
||||||
snippet deff
|
snippet deff
|
||||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||||
${3}
|
${3:# TODO: write code...}
|
||||||
# New Method
|
# New Method
|
||||||
snippet defs
|
snippet defs
|
||||||
def ${1:mname}(self, ${2:arg}):
|
def ${1:mname}(self, ${2:arg}):
|
||||||
${3:pass}
|
${3:# TODO: write code...}
|
||||||
# New Property
|
# New Property
|
||||||
snippet property
|
snippet property
|
||||||
def ${1:foo}():
|
def ${1:foo}():
|
||||||
@ -54,17 +54,17 @@ snippet property
|
|||||||
# Ifs
|
# Ifs
|
||||||
snippet if
|
snippet if
|
||||||
if ${1:condition}:
|
if ${1:condition}:
|
||||||
${2:code...}
|
${2:# TODO: write code...}
|
||||||
snippet el
|
snippet el
|
||||||
else:
|
else:
|
||||||
${1:code...}
|
${1:# TODO: write code...}
|
||||||
snippet ei
|
snippet ei
|
||||||
elif ${1:condition}:
|
elif ${1:condition}:
|
||||||
${2:code...}
|
${2:# TODO: write code...}
|
||||||
# For
|
# For
|
||||||
snippet for
|
snippet for
|
||||||
for ${1:item} in ${2:items}:
|
for ${1:item} in ${2:items}:
|
||||||
${3:code...}
|
${3:# TODO: write code...}
|
||||||
# Encodes
|
# Encodes
|
||||||
snippet cutf8
|
snippet cutf8
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
@ -79,32 +79,32 @@ snippet .
|
|||||||
self.
|
self.
|
||||||
snippet try Try/Except
|
snippet try Try/Except
|
||||||
try:
|
try:
|
||||||
${1:pass}
|
${1:# TODO: write code...}
|
||||||
except ${2:Exception}, ${3:e}:
|
except ${2:Exception}, ${3:e}:
|
||||||
${4:raise $3}
|
${4:raise $3}
|
||||||
snippet try Try/Except/Else
|
snippet try Try/Except/Else
|
||||||
try:
|
try:
|
||||||
${1:pass}
|
${1:# TODO: write code...}
|
||||||
except ${2:Exception}, ${3:e}:
|
except ${2:Exception}, ${3:e}:
|
||||||
${4:raise $3}
|
${4:raise $3}
|
||||||
else:
|
else:
|
||||||
${5:pass}
|
${5:# TODO: write code...}
|
||||||
snippet try Try/Except/Finally
|
snippet try Try/Except/Finally
|
||||||
try:
|
try:
|
||||||
${1:pass}
|
${1:# TODO: write code...}
|
||||||
except ${2:Exception}, ${3:e}:
|
except ${2:Exception}, ${3:e}:
|
||||||
${4:raise $3}
|
${4:raise $3}
|
||||||
finally:
|
finally:
|
||||||
${5:pass}
|
${5:# TODO: write code...}
|
||||||
snippet try Try/Except/Else/Finally
|
snippet try Try/Except/Else/Finally
|
||||||
try:
|
try:
|
||||||
${1:pass}
|
${1:# TODO: write code...}
|
||||||
except ${2:Exception}, ${3:e}:
|
except ${2:Exception}, ${3:e}:
|
||||||
${4:raise $3}
|
${4:raise $3}
|
||||||
else:
|
else:
|
||||||
${5:pass}
|
${5:# TODO: write code...}
|
||||||
finally:
|
finally:
|
||||||
${6:pass}
|
${6:# TODO: write code...}
|
||||||
# if __name__ == '__main__':
|
# if __name__ == '__main__':
|
||||||
snippet ifmain
|
snippet ifmain
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -130,12 +130,29 @@ snippet "
|
|||||||
# test function/method
|
# test function/method
|
||||||
snippet test
|
snippet test
|
||||||
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
|
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
|
||||||
${3:pass}
|
${3:# TODO: write code...}
|
||||||
# test case
|
# test case
|
||||||
snippet testcase
|
snippet testcase
|
||||||
class ${1:ExampleCase}(unittest.TestCase):
|
class ${1:ExampleCase}(unittest.TestCase):
|
||||||
|
|
||||||
def test_${2:description}(self):
|
def test_${2:description}(self):
|
||||||
${3:pass}
|
${3:# TODO: write code...}
|
||||||
snippet fut
|
snippet fut
|
||||||
from __future__ import ${1}
|
from __future__ import ${1}
|
||||||
|
#getopt
|
||||||
|
snippet getopt
|
||||||
|
try:
|
||||||
|
# Short option syntax: "hv:"
|
||||||
|
# Long option syntax: "help" or "verbose="
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], "${1:short_options}", [${2:long_options}])
|
||||||
|
|
||||||
|
except getopt.GetoptError, err:
|
||||||
|
# Print debug info
|
||||||
|
print str(err)
|
||||||
|
${3:error_action}
|
||||||
|
|
||||||
|
for option, argument in opts:
|
||||||
|
if option in ("-h", "--help"):
|
||||||
|
${4}
|
||||||
|
elif option in ("-v", "--verbose"):
|
||||||
|
verbose = argument
|
||||||
|
95
snippets/r.snippets
Normal file
95
snippets/r.snippets
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
snippet #!
|
||||||
|
#!/usr/bin/env Rscript
|
||||||
|
|
||||||
|
# includes
|
||||||
|
snippet lib
|
||||||
|
library(${1:package})
|
||||||
|
snippet req
|
||||||
|
require(${1:package})
|
||||||
|
snippet source
|
||||||
|
source('${1:file}')
|
||||||
|
|
||||||
|
# conditionals
|
||||||
|
snippet if
|
||||||
|
if (${1:condition}) {
|
||||||
|
${2:code}
|
||||||
|
}
|
||||||
|
snippet el
|
||||||
|
else {
|
||||||
|
${1:code}
|
||||||
|
}
|
||||||
|
snippet ei
|
||||||
|
else if (${1:condition}) {
|
||||||
|
${2:code}
|
||||||
|
}
|
||||||
|
|
||||||
|
# functions
|
||||||
|
snippet fun
|
||||||
|
${1:name} = function (${2:variables}) {
|
||||||
|
${3:code}
|
||||||
|
}
|
||||||
|
snippet ret
|
||||||
|
return(${1:code})
|
||||||
|
|
||||||
|
# dataframes, lists, etc
|
||||||
|
snippet df
|
||||||
|
${1:name}[${2:rows}, ${3:cols}]
|
||||||
|
snippet c
|
||||||
|
c(${1:items})
|
||||||
|
snippet li
|
||||||
|
list(${1:items})
|
||||||
|
snippet mat
|
||||||
|
matrix(${1:data}, nrow=${2:rows}, ncol=${3:cols})
|
||||||
|
|
||||||
|
# apply functions
|
||||||
|
snippet apply
|
||||||
|
apply(${1:array}, ${2:margin}, ${3:function})
|
||||||
|
snippet lapply
|
||||||
|
lapply(${1:list}, ${2:function})
|
||||||
|
snippet sapply
|
||||||
|
lapply(${1:list}, ${2:function})
|
||||||
|
snippet vapply
|
||||||
|
vapply(${1:list}, ${2:function}, ${3:type})
|
||||||
|
snippet mapply
|
||||||
|
mapply(${1:function}, ${2:...})
|
||||||
|
snippet tapply
|
||||||
|
tapply(${1:vector}, ${2:index}, ${3:function})
|
||||||
|
snippet rapply
|
||||||
|
rapply(${1:list}, ${2:function})
|
||||||
|
|
||||||
|
# plyr functions
|
||||||
|
snippet dd
|
||||||
|
ddply(${1:frame}, ${2:variables}, ${3:function})
|
||||||
|
snippet dl
|
||||||
|
dlply(${1:frame}, ${2:variables}, ${3:function})
|
||||||
|
snippet da
|
||||||
|
daply(${1:frame}, ${2:variables}, ${3:function})
|
||||||
|
snippet d_
|
||||||
|
d_ply(${1:frame}, ${2:variables}, ${3:function})
|
||||||
|
|
||||||
|
snippet ad
|
||||||
|
adply(${1:array}, ${2:margin}, ${3:function})
|
||||||
|
snippet al
|
||||||
|
alply(${1:array}, ${2:margin}, ${3:function})
|
||||||
|
snippet aa
|
||||||
|
aaply(${1:array}, ${2:margin}, ${3:function})
|
||||||
|
snippet a_
|
||||||
|
a_ply(${1:array}, ${2:margin}, ${3:function})
|
||||||
|
|
||||||
|
snippet ld
|
||||||
|
ldply(${1:list}, ${2:function})
|
||||||
|
snippet ll
|
||||||
|
llply(${1:list}, ${2:function})
|
||||||
|
snippet la
|
||||||
|
laply(${1:list}, ${2:function})
|
||||||
|
snippet l_
|
||||||
|
l_ply(${1:list}, ${2:function})
|
||||||
|
|
||||||
|
snippet md
|
||||||
|
mdply(${1:matrix}, ${2:function})
|
||||||
|
snippet ml
|
||||||
|
mlply(${1:matrix}, ${2:function})
|
||||||
|
snippet ma
|
||||||
|
maply(${1:matrix}, ${2:function})
|
||||||
|
snippet m_
|
||||||
|
m_ply(${1:matrix}, ${2:function})
|
@ -1,14 +1,14 @@
|
|||||||
# rst
|
# rst
|
||||||
|
|
||||||
snippet :
|
snippet :
|
||||||
:${1:Text}: ${2:blah blah}
|
:${1:field name}: ${2:field body}
|
||||||
snippet *
|
snippet *
|
||||||
*${1:Emphasis}*
|
*${1:Emphasis}*
|
||||||
snippet **
|
snippet **
|
||||||
**${1:Strong emphasis}**
|
**${1:Strong emphasis}**
|
||||||
snippet _
|
snippet _
|
||||||
\`${1:Text}\`_
|
\`${1:hyperlink-name}\`_
|
||||||
.. _\`$1\`: ${2:blah blah}
|
.. _\`$1\`: ${2:link-block}
|
||||||
snippet =
|
snippet =
|
||||||
${1:Title}
|
${1:Title}
|
||||||
=====${2:=}
|
=====${2:=}
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
# Ruby snippets - for Rails, see below #
|
# Ruby snippets - for Rails, see below #
|
||||||
########################################
|
########################################
|
||||||
|
|
||||||
|
# encoding for Ruby 1.9
|
||||||
|
snippet enc
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
# #!/usr/bin/env ruby
|
# #!/usr/bin/env ruby
|
||||||
snippet #!
|
snippet #!
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
@ -22,7 +26,7 @@ snippet beg
|
|||||||
rescue ${1:Exception} => ${2:e}
|
rescue ${1:Exception} => ${2:e}
|
||||||
end
|
end
|
||||||
|
|
||||||
snippet req
|
snippet req require
|
||||||
require "${1}"${2}
|
require "${1}"${2}
|
||||||
snippet #
|
snippet #
|
||||||
# =>
|
# =>
|
||||||
@ -390,7 +394,7 @@ snippet :
|
|||||||
snippet ope
|
snippet ope
|
||||||
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
open(${1:"path/or/url/or/pipe"}, "${2:w}") { |${3:io}| ${4} }
|
||||||
# path_from_here()
|
# path_from_here()
|
||||||
snippet patfh
|
snippet fpath
|
||||||
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}
|
||||||
# unix_filter {}
|
# unix_filter {}
|
||||||
snippet unif
|
snippet unif
|
||||||
@ -571,7 +575,7 @@ snippet asre
|
|||||||
assert_response :${1:success}, @response.body${2}
|
assert_response :${1:success}, @response.body${2}
|
||||||
snippet asrj
|
snippet asrj
|
||||||
assert_rjs :${1:replace}, "${2:dom id}"
|
assert_rjs :${1:replace}, "${2:dom id}"
|
||||||
snippet ass
|
snippet ass assert_select(..)
|
||||||
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
|
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
|
||||||
snippet bf
|
snippet bf
|
||||||
before_filter :${1:method}
|
before_filter :${1:method}
|
||||||
@ -865,7 +869,6 @@ snippet test
|
|||||||
test "should ${1:do something}" do
|
test "should ${1:do something}" do
|
||||||
${2}
|
${2}
|
||||||
end
|
end
|
||||||
|
|
||||||
#migrations
|
#migrations
|
||||||
snippet mac
|
snippet mac
|
||||||
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
|
add_column :${1:table_name}, :${2:column_name}, :${3:data_type}
|
||||||
|
@ -41,3 +41,43 @@ snippet go
|
|||||||
# Set SCRIPT_DIR variable to directory script is located.
|
# Set SCRIPT_DIR variable to directory script is located.
|
||||||
snippet sdir
|
snippet sdir
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
# getopt
|
||||||
|
snippet getopt
|
||||||
|
__ScriptVersion="${1:version}"
|
||||||
|
|
||||||
|
#=== FUNCTION ================================================================
|
||||||
|
# NAME: usage
|
||||||
|
# DESCRIPTION: Display usage information.
|
||||||
|
#===============================================================================
|
||||||
|
function usage ()
|
||||||
|
{
|
||||||
|
cat <<- EOT
|
||||||
|
|
||||||
|
Usage : $${0:0} [options] [--]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h|help Display this message
|
||||||
|
-v|version Display script version
|
||||||
|
|
||||||
|
EOT
|
||||||
|
} # ---------- end of function usage ----------
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Handle command line arguments
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
while getopts ":hv" opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
|
||||||
|
h|help ) usage; exit 0 ;;
|
||||||
|
|
||||||
|
v|version ) echo "$${0:0} -- Version $__ScriptVersion"; exit 0 ;;
|
||||||
|
|
||||||
|
\? ) echo -e "\n Option does not exist : $OPTARG\n"
|
||||||
|
usage; exit 1 ;;
|
||||||
|
|
||||||
|
esac # --- end of case ---
|
||||||
|
done
|
||||||
|
shift $(($OPTIND-1))
|
||||||
|
|
||||||
|
26
snippets/sql.snippets
Normal file
26
snippets/sql.snippets
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
snippet tbl
|
||||||
|
create table ${1:table} (
|
||||||
|
${2:columns}
|
||||||
|
);
|
||||||
|
snippet col
|
||||||
|
${1:name} ${2:type} ${3:default ''} ${4:not null}
|
||||||
|
snippet ccol
|
||||||
|
${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}
|
||||||
|
snippet ncol
|
||||||
|
${1:name} number ${3:default 0} ${4:not null}
|
||||||
|
snippet dcol
|
||||||
|
${1:name} date ${3:default sysdate} ${4:not null}
|
||||||
|
snippet ind
|
||||||
|
create index ${3:$1_$2} on ${1:table}(${2:column});
|
||||||
|
snippet uind
|
||||||
|
create unique index ${1:name} on ${2:table}(${3:column});
|
||||||
|
snippet tblcom
|
||||||
|
comment on table ${1:table} is '${2:comment}';
|
||||||
|
snippet colcom
|
||||||
|
comment on column ${1:table}.${2:column} is '${3:comment}';
|
||||||
|
snippet addcol
|
||||||
|
alter table ${1:table} add (${2:column} ${3:type});
|
||||||
|
snippet seq
|
||||||
|
create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};
|
||||||
|
snippet s*
|
||||||
|
select * from ${1:table}
|
@ -1,5 +1,3 @@
|
|||||||
# recomendation: change the fold marker from {{{,}}} to (fold),(end) ; tex uses "{" and "}" a lot
|
|
||||||
|
|
||||||
#PREAMBLE
|
#PREAMBLE
|
||||||
#newcommand
|
#newcommand
|
||||||
snippet nc
|
snippet nc
|
||||||
@ -97,40 +95,34 @@ snippet part
|
|||||||
% part $2 (end)
|
% part $2 (end)
|
||||||
# Chapter
|
# Chapter
|
||||||
snippet cha
|
snippet cha
|
||||||
\chapter{${1:chapter name}} % (fold)
|
\chapter{${1:chapter name}}
|
||||||
\label{cha:${2:$1}}
|
\label{cha:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% chapter $2 (end)
|
|
||||||
# Section
|
# Section
|
||||||
snippet sec
|
snippet sec
|
||||||
\section{${1:section name}} % (fold)
|
\section{${1:section name}}
|
||||||
\label{sec:${2:$1}}
|
\label{sec:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% section $2 (end)
|
|
||||||
# Sub Section
|
# Sub Section
|
||||||
snippet sub
|
snippet sub
|
||||||
\subsection{${1:subsection name}} % (fold)
|
\subsection{${1:subsection name}}
|
||||||
\label{sub:${2:$1}}
|
\label{sub:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% subsection $2 (end)
|
|
||||||
# Sub Sub Section
|
# Sub Sub Section
|
||||||
snippet subs
|
snippet subs
|
||||||
\subsubsection{${1:subsubsection name}} % (fold)
|
\subsubsection{${1:subsubsection name}}
|
||||||
\label{ssub:${2:$1}}
|
\label{ssub:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% subsubsection $2 (end)
|
|
||||||
# Paragraph
|
# Paragraph
|
||||||
snippet par
|
snippet par
|
||||||
\paragraph{${1:paragraph name}} % (fold)
|
\paragraph{${1:paragraph name}}
|
||||||
\label{par:${2:$1}}
|
\label{par:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% paragraph $2 (end)
|
|
||||||
# Sub Paragraph
|
# Sub Paragraph
|
||||||
snippet subp
|
snippet subp
|
||||||
\subparagraph{${1:subparagraph name}} % (fold)
|
\subparagraph{${1:subparagraph name}}
|
||||||
\label{subp:${2:$1}}
|
\label{subp:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
% subparagraph $2 (end)
|
|
||||||
#References
|
#References
|
||||||
snippet itd
|
snippet itd
|
||||||
\item[${1:description}] ${2:item}
|
\item[${1:description}] ${2:item}
|
||||||
@ -146,9 +138,11 @@ snippet page
|
|||||||
${1:page}~\pageref{${2}}${3}
|
${1:page}~\pageref{${2}}${3}
|
||||||
snippet index
|
snippet index
|
||||||
\index{${1:index}}${2}
|
\index{${1:index}}${2}
|
||||||
#cite
|
#Citations
|
||||||
snippet cite
|
snippet cite
|
||||||
\cite{${1}}${2}
|
\cite[${1}]{${2}}${3}
|
||||||
|
snippet fcite
|
||||||
|
\footcite[${1}]{${2}}${3}
|
||||||
#Formating text: italic, bold, underline, small capital, emphase ..
|
#Formating text: italic, bold, underline, small capital, emphase ..
|
||||||
snippet it
|
snippet it
|
||||||
\textit{${1:text}}
|
\textit{${1:text}}
|
||||||
|
97
snippets/xslt.snippets
Normal file
97
snippets/xslt.snippets
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
snippet apply-templates with-param
|
||||||
|
<xsl:apply-templates select="${1:*}">
|
||||||
|
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
|
||||||
|
</xsl:apply-templates>${5}
|
||||||
|
|
||||||
|
snippet apply-templates sort-by
|
||||||
|
<xsl:apply-templates select="${1:*}">
|
||||||
|
<xsl:sort select="${2:node}" order="${3:ascending}" data-type="${4:text}">${5}
|
||||||
|
</xsl:apply-templates>${6}
|
||||||
|
|
||||||
|
snippet apply-templates plain
|
||||||
|
<xsl:apply-templates select="${1:*}" />${2}
|
||||||
|
|
||||||
|
snippet attribute blank
|
||||||
|
<xsl:attribute name="${1:name}">${2}</xsl:attribute>${3}
|
||||||
|
|
||||||
|
snippet attribute value-of
|
||||||
|
<xsl:attribute name="${1:name}">
|
||||||
|
<xsl:value-of select="${2:*}" />
|
||||||
|
</xsl:attribute>${3}
|
||||||
|
|
||||||
|
snippet call-template
|
||||||
|
<xsl:call-template name="${1:template}" />
|
||||||
|
|
||||||
|
snippet call-template with-param
|
||||||
|
<xsl:call-template name="${1:template}">
|
||||||
|
<xsl:with-param name="${2:param}">${3}</xsl:with-param>${4}
|
||||||
|
</xsl:call-template>${5}
|
||||||
|
|
||||||
|
snippet choose
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="${1:value}">
|
||||||
|
${2}
|
||||||
|
</xsl:when>${3}
|
||||||
|
</xsl:choose>
|
||||||
|
|
||||||
|
snippet copy-of
|
||||||
|
<xsl:copy-of select="${1:*}" />${2}
|
||||||
|
|
||||||
|
snippet for-each
|
||||||
|
<xsl:for-each select="${1:*}">${2}
|
||||||
|
</xsl:for-each>${3}
|
||||||
|
|
||||||
|
snippet if
|
||||||
|
<xsl:if test="${1:test}">${2}
|
||||||
|
</xsl:if>${3}
|
||||||
|
|
||||||
|
snippet import
|
||||||
|
<xsl:import href="${1:stylesheet}" />${2}
|
||||||
|
|
||||||
|
snippet include
|
||||||
|
<xsl:include href="${1:stylesheet}" />${2}
|
||||||
|
|
||||||
|
snippet otherwise
|
||||||
|
<xsl:otherwise>${1}
|
||||||
|
</xsl:otherwise>
|
||||||
|
|
||||||
|
snippet param
|
||||||
|
<xsl:param name="${1:name}">${2}
|
||||||
|
</xsl:param>${3}
|
||||||
|
|
||||||
|
snippet stylesheet
|
||||||
|
<xsl:stylesheet version="1.0"
|
||||||
|
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">${1}
|
||||||
|
</xsl:stylesheet>
|
||||||
|
|
||||||
|
snippet template
|
||||||
|
<xsl:template match="${1:*}">${3}
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
snippet template named
|
||||||
|
<xsl:template name="${1:name}">${2}
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
snippet text
|
||||||
|
<xsl:text>${1}</xsl:text>
|
||||||
|
|
||||||
|
snippet value-of
|
||||||
|
<xsl:value-of select="${1:*}" />${2}
|
||||||
|
|
||||||
|
snippet variable blank
|
||||||
|
<xsl:variable name="${1:name}">${2}
|
||||||
|
</xsl:variable>
|
||||||
|
|
||||||
|
snippet variable select
|
||||||
|
<xsl:variable select="${1:*}" />${2}
|
||||||
|
|
||||||
|
snippet when
|
||||||
|
<xsl:when test="${1:test}">${2}
|
||||||
|
</xsl:when>
|
||||||
|
|
||||||
|
snippet with-param
|
||||||
|
<xsl:with-param name="${1:name}">${2}</xsl:with-param>
|
||||||
|
|
||||||
|
snippet with-param select
|
||||||
|
<xsl:with-param name="${1:name}" select="${2:*}" />
|
||||||
|
|
248
snippets/yii-chtml.snippets
Normal file
248
snippets/yii-chtml.snippets
Normal file
@ -0,0 +1,248 @@
|
|||||||
|
#--------------------Yii CHtml---------------------------------
|
||||||
|
#Yii CHtml::radioButton
|
||||||
|
snippet yhrb
|
||||||
|
echo CHtml::radioButton('${1:name}', ${2:false},array(${3:optionName}=>${4:optionValue} );
|
||||||
|
|
||||||
|
#Yii CHtml::asset
|
||||||
|
snippet yhass
|
||||||
|
echo CHtml::asset('${1:path}');
|
||||||
|
|
||||||
|
#Yii CHtml::activeLabelEx
|
||||||
|
snippet yhale
|
||||||
|
echo CHtml::activeLabelEx(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::encodeArray
|
||||||
|
snippet yheca
|
||||||
|
echo CHtml::encodeArray(array(${1}));
|
||||||
|
|
||||||
|
#Yii CHtml::normalizeUrl
|
||||||
|
snippet yhnurl
|
||||||
|
echo CHtml::normalizeUrl(array('${1}'));
|
||||||
|
|
||||||
|
#Yii CHtml::resetButton
|
||||||
|
snippet yhsb
|
||||||
|
echo CHtml::submitButton('${1:label}',array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::linkButton
|
||||||
|
snippet yhlinkb
|
||||||
|
echo CHtml::linkButton('${1:lable}',array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeTextArea
|
||||||
|
snippet yhata
|
||||||
|
echo CHtml::activeTextArea(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::ajaxButton
|
||||||
|
snippet yhajb
|
||||||
|
echo CHtml::ajaxButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeId
|
||||||
|
snippet yhai
|
||||||
|
echo CHtml::activeId(${1:model}, '${2:attribute}');
|
||||||
|
|
||||||
|
#Yii CHtml::activeCheckBox
|
||||||
|
snippet yhacb
|
||||||
|
echo CHtml::activeCheckBox(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeHiddenField
|
||||||
|
snippet yhahf
|
||||||
|
echo CHtml::activeHiddenField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::encode
|
||||||
|
snippet yhec
|
||||||
|
echo CHtml::encode(${1:text});
|
||||||
|
|
||||||
|
#Yii CHtml::metaTag
|
||||||
|
snippet yhmtag
|
||||||
|
echo CHtml::metaTag('${1:content}', '${2:name}', '${3:httpEquiv}',array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::dropDownList
|
||||||
|
snippet yhddl
|
||||||
|
echo CHtml::dropDownList('${1:name}', '${2:select}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::listBox
|
||||||
|
snippet yhlb
|
||||||
|
echo CHtml::listBox('${1:name}', '${2:select}',array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::script
|
||||||
|
snippet yhjs
|
||||||
|
echo CHtml::script('${1:test}');
|
||||||
|
|
||||||
|
#Yii CHtml::ajax
|
||||||
|
snippet yhaj
|
||||||
|
echo CHtml::ajax(array(${1}));
|
||||||
|
|
||||||
|
#Yii CHtml::textField
|
||||||
|
snippet yhtf
|
||||||
|
echo CHtml::textField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activePasswordField
|
||||||
|
snippet yhapf
|
||||||
|
echo CHtml::activePasswordField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::listData
|
||||||
|
snippet yhld
|
||||||
|
echo CHtml::listData(array(${1}),'${2:valueField}', '${3:textField}','${4:groupField}');
|
||||||
|
|
||||||
|
#Yii CHtml::mailto
|
||||||
|
snippet yhmt
|
||||||
|
echo CHtml::mailto('${1:text}', '${2:email}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::image
|
||||||
|
snippet yhimg
|
||||||
|
echo CHtml::image('${1:src}', '${2:alt}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeListBox
|
||||||
|
snippet yhalb
|
||||||
|
echo CHtml::activeListBox(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeFileField
|
||||||
|
snippet yhaff
|
||||||
|
echo CHtml::activeFileField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::closeTag
|
||||||
|
snippet yhct
|
||||||
|
echo CHtml::closeTag('${1:tag}');
|
||||||
|
|
||||||
|
#Yii CHtml::activeInputField
|
||||||
|
snippet yhaif
|
||||||
|
echo CHtml::activeInputField('${1:type}', ${2:model}, '${3:attribute}',array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::scriptFile
|
||||||
|
snippet yhjsf
|
||||||
|
echo CHtml::scriptFile('${1:url}');
|
||||||
|
|
||||||
|
#Yii CHtml::radioButtonList
|
||||||
|
snippet yhrbl
|
||||||
|
echo CHtml::radioButtonList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::cssFile
|
||||||
|
snippet yhcssf
|
||||||
|
echo CHtml::cssFile('${1:url}','${2:media}');
|
||||||
|
|
||||||
|
#Yii CHtml::error
|
||||||
|
snippet yherr
|
||||||
|
echo CHtml::error(${1:model}, '${2:attribute}');
|
||||||
|
|
||||||
|
#Yii CHtml::passwordField
|
||||||
|
snippet yhpf
|
||||||
|
echo CHtml::passwordField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::hiddenField
|
||||||
|
snippet yhhf
|
||||||
|
echo CHtml::hiddenField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::cdata
|
||||||
|
snippet yhc
|
||||||
|
echo CHtml::cdata(${1:text});
|
||||||
|
|
||||||
|
#Yii CHtml::link
|
||||||
|
snippet yhlink
|
||||||
|
echo CHtml::link('${1:text}',array(${2}),array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::errorSummary
|
||||||
|
snippet yherrs
|
||||||
|
echo CHtml::errorSummary(${1:model},'${2:headerHtml}','${3:footerHtml}');
|
||||||
|
|
||||||
|
#Yii CHtml::tag
|
||||||
|
snippet yht
|
||||||
|
echo CHtml::tag('${1:tag}',array('${2:optionName}'=>${3:optionValue}),${4:false},${5:true});
|
||||||
|
|
||||||
|
#Yii CHtml::ajaxLink
|
||||||
|
snippet yhajl
|
||||||
|
echo CHtml::ajaxLink('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::label
|
||||||
|
snippet yhlabel
|
||||||
|
echo CHtml::label('${1:label}', '${2:for}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeName
|
||||||
|
snippet yhan
|
||||||
|
echo CHtml::activeName(${1:model}, '${2:attribute}');
|
||||||
|
|
||||||
|
#Yii CHtml::statefulForm
|
||||||
|
snippet yhsform
|
||||||
|
echo CHtml::statefulForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::fileField
|
||||||
|
snippet yhff
|
||||||
|
echo CHtml::fileField('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeTextField
|
||||||
|
snippet yhatf
|
||||||
|
echo CHtml::activeTextField(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::css
|
||||||
|
snippet yhcss
|
||||||
|
echo CHtml::css('${1:test}','${2:media}');
|
||||||
|
|
||||||
|
#Yii CHtml::imageButton
|
||||||
|
snippet yhimgb
|
||||||
|
echo CHtml::imageButton('${1:src}',array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::ajaxSubmitButton
|
||||||
|
snippet yhajsb
|
||||||
|
echo CHtml::ajaxSubmitButton('${1:label}', '${2:url}',array('${3:ajaxOptionName}'=>${4:ajaxOptionValue}),array('${5:optionName}'=>${6:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::button
|
||||||
|
snippet yhb
|
||||||
|
echo CHtml::button('${1:label}',array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::listOptions
|
||||||
|
snippet yhlo
|
||||||
|
echo CHtml::listOptions('${1:selection}', array(${2}), array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeCheckBoxList
|
||||||
|
snippet yhacbl
|
||||||
|
echo CHtml::activeCheckBoxList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::openTag
|
||||||
|
snippet yhot
|
||||||
|
echo CHtml::openTag('${1:tag}', array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::checkBox
|
||||||
|
snippet yhcb
|
||||||
|
echo CHtml::checkBox('${1:name}', ${2:false}, array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::textArea
|
||||||
|
snippet yhta
|
||||||
|
echo CHtml::textArea('${1:name}', '${2:value}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::linkTag
|
||||||
|
snippet yhlinkt
|
||||||
|
echo CHtml::linkTag('${1:relation}', '${2:type}', '${3:href}', '${4:media}',array('${5:optionName}'=>${6:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::resetButton
|
||||||
|
snippet yhrsb
|
||||||
|
echo CHtml::resetButton('${1:label}',array('${2:optionName}'=>${3:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeRadioButtonList
|
||||||
|
snippet yharbl
|
||||||
|
echo CHtml::activeRadioButtonList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::checkBoxList
|
||||||
|
snippet yhcbl
|
||||||
|
echo CHtml::checkBoxList('${1:name}', ${2:select}, array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::form
|
||||||
|
snippet yhform
|
||||||
|
echo CHtml::form(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::beginForm
|
||||||
|
snippet yhbeform
|
||||||
|
echo CHtml::beginForm(array('${1}'), '${2:post}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
${5}
|
||||||
|
echo CHtml::endForm();
|
||||||
|
|
||||||
|
#Yii CHtml::activeDropDownList
|
||||||
|
snippet yhaddl
|
||||||
|
echo CHtml::activeDropDownList(${1:model}, '${2:attribute}', array(${3}),array('${4:optionName}'=>${5:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeRadioButton
|
||||||
|
snippet yharb
|
||||||
|
echo CHtml::activeRadioButton(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
#Yii CHtml::activeLabel
|
||||||
|
snippet yhal
|
||||||
|
echo CHtml::activeLabel(${1:model}, '${2:attribute}',array('${3:optionName}'=>${4:optionValue}));
|
||||||
|
|
||||||
|
|
300
snippets/yii.snippets
Normal file
300
snippets/yii.snippets
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
#Yii session offset
|
||||||
|
snippet yse
|
||||||
|
Yii::app()->session['${1}'];
|
||||||
|
|
||||||
|
#Yii renderDynamic
|
||||||
|
snippet yrd
|
||||||
|
$this->renderDynamic('${1:callback}');
|
||||||
|
|
||||||
|
#Yii set cache
|
||||||
|
snippet ycas
|
||||||
|
Yii::app()->cache->set('${1:key}', ${2:value}, ${3:expire}, new C${4:}CacheDependency(${5}));
|
||||||
|
|
||||||
|
#Yii Add cache
|
||||||
|
snippet ycad
|
||||||
|
Yii::app()->cache->add('${1:key}', ${2:value}, ${3:expire}, new C${4}CacheDependency(${5}));
|
||||||
|
|
||||||
|
#Yii register CSS file
|
||||||
|
snippet yregcf
|
||||||
|
Yii::app()->clientScript->registerCssFile('${1:file}');
|
||||||
|
|
||||||
|
#Yii requestType
|
||||||
|
snippet yreqtype
|
||||||
|
Yii::app()->request->requestType
|
||||||
|
|
||||||
|
#Yii isAjaxRequest
|
||||||
|
snippet yisajax
|
||||||
|
Yii::app()->request->isAjaxRequest
|
||||||
|
|
||||||
|
#Yii translate
|
||||||
|
snippet yt
|
||||||
|
Yii::t('${1:category}', '${2:message}',array(${3}));
|
||||||
|
|
||||||
|
#Yii register CSS
|
||||||
|
snippet yregc
|
||||||
|
Yii::app()->clientScript->registerCss('${1:id}', '${2}');
|
||||||
|
|
||||||
|
#Yii log
|
||||||
|
snippet ylog
|
||||||
|
Yii::log('${1:msg}', '${2:info}');
|
||||||
|
|
||||||
|
#Yii userHostAddress
|
||||||
|
snippet yuserip
|
||||||
|
YYii::app()->request->userHostAddress
|
||||||
|
|
||||||
|
#Yii register script file
|
||||||
|
snippet yregsf
|
||||||
|
Yii::app()->clientScript->registerScriptFile('${1:scriptUrl}', CClientScript::POS_${2:END});
|
||||||
|
|
||||||
|
#Yii CLinkPager
|
||||||
|
snippet ylinkpager
|
||||||
|
$this->widget('CLinkPager', array('pages'=>$pages,'header'=>'${1}'}))
|
||||||
|
|
||||||
|
#Yii CJSON::encode
|
||||||
|
snippet yjec
|
||||||
|
CJSON::encode(${1:text});
|
||||||
|
|
||||||
|
#CActiveDataProvider
|
||||||
|
snippet yadp
|
||||||
|
$dataProvider = new CActiveDataProvider('${1}', array(
|
||||||
|
'criteria' => array(
|
||||||
|
'condition' => '${2}',
|
||||||
|
'order' => '${3}',
|
||||||
|
'with' => array('${4}')
|
||||||
|
),
|
||||||
|
//'pagination' => false,
|
||||||
|
'pagination' => array(
|
||||||
|
'pageSize'=>${5},
|
||||||
|
),
|
||||||
|
));
|
||||||
|
${6}
|
||||||
|
// $dataProvider->getData() will return a list of Post objects
|
||||||
|
|
||||||
|
#Yii renderDynamic internal
|
||||||
|
snippet yrdi
|
||||||
|
$this->renderDynamic('${1:callback}', array('${2:key}'=>${3:value}));
|
||||||
|
|
||||||
|
#Yii register script
|
||||||
|
snippet yregs
|
||||||
|
Yii::app()->clientScript->registerScript('${1:id}', '${2}', CClientScript::POS_${3:READY});
|
||||||
|
|
||||||
|
#Yii Flush cache
|
||||||
|
snippet ycaf
|
||||||
|
Yii::app()->cache->flush();
|
||||||
|
|
||||||
|
#Yii Yii::app()->request->cookies
|
||||||
|
snippet yco
|
||||||
|
Yii::app()->request->cookies['${1}']
|
||||||
|
|
||||||
|
#Yii user->
|
||||||
|
snippet yuser
|
||||||
|
Yii::app()->user->${1}
|
||||||
|
|
||||||
|
#Yii refresh
|
||||||
|
snippet yrf
|
||||||
|
$this->refresh();
|
||||||
|
|
||||||
|
#Yii import
|
||||||
|
snippet yimp
|
||||||
|
Yii::import('${1}');
|
||||||
|
|
||||||
|
#Yii trace
|
||||||
|
snippet ytrace
|
||||||
|
Yii::trace('${1:msg}');
|
||||||
|
|
||||||
|
#Yii params
|
||||||
|
snippet ypar
|
||||||
|
Yii::app()->params['${1}']
|
||||||
|
|
||||||
|
#Yii isPostRequest
|
||||||
|
snippet yispost
|
||||||
|
Yii::app()->request->isPostRequest
|
||||||
|
|
||||||
|
#Yii IF isAjaxRequest
|
||||||
|
snippet yifisajax
|
||||||
|
if(Yii::app()->request->isAjaxRequest == TRUE)
|
||||||
|
{
|
||||||
|
${1}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Yii Yii::app()->cache->delete
|
||||||
|
snippet ydelcache
|
||||||
|
Yii::app()->cache->delete('${1:key}');
|
||||||
|
|
||||||
|
#Yii render view
|
||||||
|
snippet yr
|
||||||
|
$this->render('${1:view}',array('${2:key}'=>${3:value}));
|
||||||
|
|
||||||
|
#Yii redirect
|
||||||
|
snippet yre
|
||||||
|
$this->redirect(array('${1:controller}/${2:action}'));
|
||||||
|
|
||||||
|
#Yii Get cache
|
||||||
|
snippet ycag
|
||||||
|
Yii::app()->cache->get('${1:key}');
|
||||||
|
|
||||||
|
#Yii render text
|
||||||
|
snippet yrt
|
||||||
|
$this->renderText('${1}');
|
||||||
|
|
||||||
|
#Yii render partial
|
||||||
|
snippet yrp
|
||||||
|
$this->renderPartial('${1:view}',array('${2:key}'=>${3:value}));
|
||||||
|
|
||||||
|
#----------------Yii Model-----------------------------
|
||||||
|
#Yii Model count
|
||||||
|
snippet ycountm
|
||||||
|
${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model countBySql
|
||||||
|
snippet ycountbs
|
||||||
|
${1:ModelName}::model()->countBySql(${2:sql},array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model updateAll
|
||||||
|
snippet yupdatea
|
||||||
|
${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${5:value}));
|
||||||
|
|
||||||
|
#Yii Model updateByPk
|
||||||
|
snippet yupdatebp
|
||||||
|
${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${6:value}));
|
||||||
|
|
||||||
|
#Yii Model deleteAll
|
||||||
|
snippet ydela
|
||||||
|
${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model deleteByPk
|
||||||
|
snippet ydelbp
|
||||||
|
${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value}));
|
||||||
|
|
||||||
|
#Yii Model find
|
||||||
|
snippet yfind
|
||||||
|
${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model findAll
|
||||||
|
snippet yfinda
|
||||||
|
${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model findByPk
|
||||||
|
snippet yfindbp
|
||||||
|
${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${5:value}));
|
||||||
|
|
||||||
|
#Yii Model findAllByPk
|
||||||
|
snippet yfindabp
|
||||||
|
${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${5:value}));
|
||||||
|
|
||||||
|
#Yii Model findBySql
|
||||||
|
snippet yfindbs
|
||||||
|
${1:ModelName}::model()->findBySql(${2:sql}, array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Model findAllByAttributes
|
||||||
|
snippet yfindaba
|
||||||
|
${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${6:value}));
|
||||||
|
|
||||||
|
#Yii Model exists
|
||||||
|
snippet yexists
|
||||||
|
${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${4:value}));
|
||||||
|
|
||||||
|
#Yii Create model class
|
||||||
|
snippet ymodel
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ${1:ModelName} extends ${2:CActiveRecord}
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the static model of the specified AR class.
|
||||||
|
* @return CActiveRecord the static model class
|
||||||
|
*/
|
||||||
|
public static function model($className=__CLASS__)
|
||||||
|
{
|
||||||
|
return parent::model($className);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string the associated database table name
|
||||||
|
*/
|
||||||
|
public function tableName()
|
||||||
|
{
|
||||||
|
return '${3:table_name}';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array validation rules for model attributes.
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array relational rules.
|
||||||
|
*/
|
||||||
|
public function relations()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array customized attribute labels (name=>label)
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------Yii Controller------------------------------------
|
||||||
|
|
||||||
|
#Yii Create controller class
|
||||||
|
snippet ycontroller
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${1:}
|
||||||
|
*/
|
||||||
|
class ${2:Site}Controller extends ${3:CController}
|
||||||
|
{
|
||||||
|
public function action${4:Index}()
|
||||||
|
{
|
||||||
|
${5}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------
|
||||||
|
// Uncomment the following methods and override them if needed
|
||||||
|
/*
|
||||||
|
public function filters()
|
||||||
|
{
|
||||||
|
// return the filter configuration for this controller, e.g.:
|
||||||
|
return array(
|
||||||
|
'inlineFilterName',
|
||||||
|
array(
|
||||||
|
'class'=>'path.to.FilterClass',
|
||||||
|
'propertyName'=>'propertyValue',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function actions()
|
||||||
|
{
|
||||||
|
// return external action classes, e.g.:
|
||||||
|
return array(
|
||||||
|
'action1'=>'path.to.ActionClass',
|
||||||
|
'action2'=>array(
|
||||||
|
'class'=>'path.to.AnotherActionClass',
|
||||||
|
'propertyName'=>'propertyValue',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#Yii Create controller action method
|
||||||
|
snippet yact
|
||||||
|
public function action${1:Index}(${2:params})
|
||||||
|
{
|
||||||
|
${3}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user