Merge pull request #220 from yydonny/master
Some improvements to the snippets of CoffeeScript
This commit is contained in:
commit
56fe095802
@ -1,21 +1,21 @@
|
|||||||
# From the TextMate bundle
|
# From the TextMate bundle
|
||||||
|
# with some modification
|
||||||
|
|
||||||
snippet fun "Function" b
|
snippet fun "Function" b
|
||||||
${1:name} = (${2:args}) ->
|
${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`->
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet bfun "Function (bound)" b
|
snippet bfun "Function (bound)" i
|
||||||
${1:(${2:args}) }=>
|
`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr}
|
||||||
${0:# body...}
|
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet if "If" b
|
snippet if "If"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet ife "If .. Else" b
|
snippet ife "If .. Else"
|
||||||
if ${1:condition}
|
if ${1:condition}
|
||||||
${2:# body...}
|
${2:# body...}
|
||||||
else
|
else
|
||||||
@ -27,49 +27,57 @@ else if ${1:condition}
|
|||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet ifte "Ternary if" b
|
snippet ifte "Ternary if"
|
||||||
if ${1:condition} then ${2:value} else ${3:other}
|
if ${1:condition} then ${2:value} else ${3:other}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet unl "Unless" b
|
snippet unl "Unless"
|
||||||
${1:action} unless ${2:condition}
|
${1:action} unless ${2:condition}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet fora "Array Comprehension" b
|
snippet fora "Array Comprehension"
|
||||||
for ${1:name} in ${2:array}
|
for ${1:name} in ${2:array}
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet foro "Object Comprehension" b
|
snippet foro "Object Comprehension"
|
||||||
for ${1:key}, ${2:value} of ${3:Object}
|
for ${1:key}, ${2:value} of ${3:Object}
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet forr "Range Comprehension (inclusive)" b
|
snippet forr "Range Comprehension (inclusive)"
|
||||||
for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}}
|
for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet forrex "Range Comprehension (exclusive)" b
|
snippet forrex "Range Comprehension (exclusive)"
|
||||||
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}}
|
for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
|
||||||
${0:# body...}
|
${0:# body...}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet swi "Switch" b
|
snippet swi "Switch"
|
||||||
switch ${1:object}
|
switch ${1:object}
|
||||||
when ${2:value}
|
when ${2:value}
|
||||||
${0:# body...}
|
${3:# body...}
|
||||||
|
else
|
||||||
|
$0
|
||||||
|
endsnippet
|
||||||
|
|
||||||
|
snippet swit "Switch when .. then"
|
||||||
|
switch ${1:object}
|
||||||
|
when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value}
|
||||||
|
else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet cla "Class" b
|
snippet cla "Class" b
|
||||||
class ${1:ClassName}${2: extends ${3:Ancestor}}
|
class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor}
|
||||||
|
|
||||||
${4:constructor: (${5:args}) ->
|
${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` ->
|
||||||
${6:# body...}}
|
${5:# body...}}
|
||||||
$7
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet try "Try .. Catch" b
|
snippet try "Try .. Catch"
|
||||||
try
|
try
|
||||||
$1
|
$1
|
||||||
catch ${2:error}
|
catch ${2:error}
|
||||||
@ -80,7 +88,7 @@ snippet req "Require" b
|
|||||||
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
|
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet # "Interpolated Code"
|
snippet # "Interpolated Code" i
|
||||||
#{$1}$0
|
#{$1}$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user