Skip to content

Commit 3f7061a

Browse files
committed
Merge pull request honza#305 from tUrG0n/master
Big Enhancements for Coffeescript. Fixed Bugs with js
2 parents c022251 + 9bee487 commit 3f7061a

7 files changed

+645
-14
lines changed
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
## Global Snippets
2+
# Define a new Angular Controller;
3+
# You can change the controller name and parameters
4+
snippet ngc
5+
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
6+
${4}
7+
# angular.foreach loop
8+
snippet ngfor
9+
angular.forEach ${1:iterateOver}, (value, key) ->
10+
${2}
11+
## Module Based Snippets
12+
# A new angular module without a config function
13+
snippet ngm
14+
angular.module '${1:moduleName}', [${2:moduleDependencies}]
15+
${3}
16+
# A new angular module without a config function and a variable assignment
17+
snippet ngma
18+
${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
19+
${3}
20+
# A new angular module with a config function
21+
snippet ngmc
22+
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
23+
${4}
24+
)
25+
# A factory in a module
26+
snippet ngmfa
27+
factory '${1:factoryName}', (${2:dependencies}) ->
28+
${3}
29+
# Define an Angular Module Service to be attached to a previously defined module
30+
# You can change the service name and service injectables
31+
snippet ngms
32+
service '${1:serviceName}', (${2:injectables}) ->
33+
${3}
34+
# Define an Angular Module Filter to be attached to a previously defined module
35+
# You can change the filter name
36+
snippet ngmfi
37+
filter '${1:filterName}', (${2:injectables}) ->
38+
(input, ${3:args}) ->
39+
${4}
40+
## Route Based Snippets
41+
# Defines a when condition of an AngularJS route
42+
snippet ngrw
43+
$routeProvider.when '${1:url}',
44+
templateUrl: '${2:templateUrl}'
45+
controller: '${3:controller}'
46+
${4}
47+
# Defines a when condition of an AngularJS route with the resolve block
48+
snippet ngrwr
49+
$routeProvider.when '${1:url}',
50+
templateUrl: '${2:templateUrl}'
51+
controller: '${3:controller}'
52+
resolve:
53+
${4}
54+
${5}
55+
# Defines an otherwise condition of an AngularJS route
56+
snippet ngro
57+
$routeProvider.otherwise redirectTo: '${1:url}'
58+
${2}
59+
## Scope Related Snippets
60+
# Define a new $scope'd function (usually inside an AngularJS Controller)
61+
# You can change the function name and arguments
62+
snippet $f
63+
$scope.${1:functionName} = (${2:args}) ->
64+
${3}
65+
# Defines a new $scope'd variable inside an AngularJS controller
66+
snippet $v
67+
$scope.${1:variable} = ${2:value}
68+
${3}
69+
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
70+
snippet $va
71+
$scope.${1:variable} = ${2:variable}
72+
${3}
73+
# Define a $watch for an expression
74+
# You can change the expression to be watched
75+
snippet $w
76+
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
77+
${2}
78+
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
79+
# You can change the event name to listen on
80+
snippet $on
81+
$scope.$on '${1:eventName}', (event, ${2:args}) ->
82+
${3}
83+
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
84+
# You can change the event name and optional event arguments
85+
snippet $b
86+
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
87+
${3}
88+
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
89+
# You can change the event name and optional event arguments
90+
snippet $e
91+
$scope.$emit '${1:eventName}', ${2:eventArgs}
92+
${3}
93+
## Directive related snippets
94+
# A compile function
95+
snippet ngdcf
96+
compile = (tElement, tAttrs, transclude) ->
97+
(scope, element, attrs) ->
98+
${1}
99+
# A linking function in a directive
100+
snippet ngdlf
101+
(scope, element, attrs${1:ctrl}) ->
102+
${2}
103+
# A directive with a compile function
104+
snippet ngdc
105+
directive '${1:directiveName}', factory = (${2:injectables}) ->
106+
directiveDefinitionObject =
107+
${3:directiveAttrs}
108+
compile: compile = (tElement, tAttrs, transclude) ->
109+
(scope, element, attrs) ->
110+
directiveDefinitionObject
111+
# A directive with a linking function only
112+
snippet ngdl
113+
.directive('${1:directiveName}', (${2:directiveDeps}) ->
114+
(scope, element, attrs${3:ctrl}) ->
115+
${4}
116+
)

snippets/coffee.snippets snippets/coffee/coffee.snippets

+5-13
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,8 @@ snippet req
9494
snippet exp
9595
${0:root} = exports ? this
9696

97-
98-
snippet ajax
99-
$.ajax
100-
url: "${1:mydomain.com/url}"
101-
type: "${2:POST}"
102-
dataType: "${3:xml/html/script/json}"
103-
data: ${4:data}
104-
complete: (jqXHR, textStatus) ->
105-
${5:// callback}
106-
success: (data, textStatus, jqXHR) ->
107-
${6:// success callback}
108-
error: (jqXHR, textStatus, errorThrown) ->
109-
${0:// error callback}
97+
snippet jsonp
98+
JSON.parse ${0:jstr}
99+
# JSON.stringify
100+
snippet jsons
101+
JSON.stringify ${0:object}

0 commit comments

Comments
 (0)