coffee.snippets 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Closure loop
  2. snippet forindo
  3. for ${1:name} in ${2:array}
  4. do ($1) ->
  5. ${3:// body}
  6. # Array comprehension
  7. snippet fora
  8. for ${1:name} in ${2:array}
  9. ${3:// body...}
  10. # Object comprehension
  11. snippet foro
  12. for ${1:key}, ${2:value} of ${3:object}
  13. ${4:// body...}
  14. # Range comprehension (inclusive)
  15. snippet forr
  16. for ${1:name} in [${2:start}..${3:finish}]
  17. ${4:// body...}
  18. snippet forrb
  19. for ${1:name} in [${2:start}..${3:finish}] by ${4:step}
  20. ${5:// body...}
  21. # Range comprehension (exclusive)
  22. snippet forrex
  23. for ${1:name} in [${2:start}...${3:finish}]
  24. ${4:// body...}
  25. snippet forrexb
  26. for ${1:name} in [${2:start}...${3:finish}] by ${4:step}
  27. ${5:// body...}
  28. # Function
  29. snippet fun
  30. (${1:args}) ->
  31. ${2:// body...}
  32. # Function (bound)
  33. snippet bfun
  34. (${1:args}) =>
  35. ${2:// body...}
  36. # Class
  37. snippet cla class ..
  38. class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
  39. ${2}
  40. snippet cla class .. constructor: ..
  41. class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`}
  42. constructor: (${2:args}) ->
  43. ${3}
  44. ${4}
  45. snippet cla class .. extends ..
  46. class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
  47. ${3}
  48. snippet cla class .. extends .. constructor: ..
  49. class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass}
  50. constructor: (${3:args}) ->
  51. ${4}
  52. ${5}
  53. # If
  54. snippet if
  55. if ${1:condition}
  56. ${2:// body...}
  57. # If __ Else
  58. snippet ife
  59. if ${1:condition}
  60. ${2:// body...}
  61. else
  62. ${3:// body...}
  63. # Else if
  64. snippet elif
  65. else if ${1:condition}
  66. ${2:// body...}
  67. # Ternary If
  68. snippet ifte
  69. if ${1:condition} then ${2:value} else ${3:other}
  70. # Unless
  71. snippet unl
  72. ${1:action} unless ${2:condition}
  73. # Switch
  74. snippet swi
  75. switch ${1:object}
  76. when ${2:value}
  77. ${3:// body...}
  78. # Log
  79. snippet log
  80. console.log ${1}
  81. # Try __ Catch
  82. snippet try
  83. try
  84. ${1}
  85. catch ${2:error}
  86. ${3}
  87. # Require
  88. snippet req
  89. ${2:$1} = require '${1:sys}'${3}
  90. # Export
  91. snippet exp
  92. ${1:root} = exports ? this