Skip to content

Commit

Permalink
Merge pull request honza#305 from tUrG0n/master
Browse files Browse the repository at this point in the history
Big Enhancements for Coffeescript. Fixed Bugs with js
  • Loading branch information
honza committed Mar 3, 2014
2 parents c022251 + 9bee487 commit 3f7061a
Show file tree
Hide file tree
Showing 7 changed files with 645 additions and 14 deletions.
116 changes: 116 additions & 0 deletions snippets/coffee/angular_coffee.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
## Global Snippets
# Define a new Angular Controller;
# You can change the controller name and parameters
snippet ngc
${1:controllerName} = (${2:scope}, ${3:injectables}) ->
${4}
# angular.foreach loop
snippet ngfor
angular.forEach ${1:iterateOver}, (value, key) ->
${2}
## Module Based Snippets
# A new angular module without a config function
snippet ngm
angular.module '${1:moduleName}', [${2:moduleDependencies}]
${3}
# A new angular module without a config function and a variable assignment
snippet ngma
${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
${3}
# A new angular module with a config function
snippet ngmc
${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
${4}
)
# A factory in a module
snippet ngmfa
factory '${1:factoryName}', (${2:dependencies}) ->
${3}
# Define an Angular Module Service to be attached to a previously defined module
# You can change the service name and service injectables
snippet ngms
service '${1:serviceName}', (${2:injectables}) ->
${3}
# Define an Angular Module Filter to be attached to a previously defined module
# You can change the filter name
snippet ngmfi
filter '${1:filterName}', (${2:injectables}) ->
(input, ${3:args}) ->
${4}
## Route Based Snippets
# Defines a when condition of an AngularJS route
snippet ngrw
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
${4}
# Defines a when condition of an AngularJS route with the resolve block
snippet ngrwr
$routeProvider.when '${1:url}',
templateUrl: '${2:templateUrl}'
controller: '${3:controller}'
resolve:
${4}
${5}
# Defines an otherwise condition of an AngularJS route
snippet ngro
$routeProvider.otherwise redirectTo: '${1:url}'
${2}
## Scope Related Snippets
# Define a new $scope'd function (usually inside an AngularJS Controller)
# You can change the function name and arguments
snippet $f
$scope.${1:functionName} = (${2:args}) ->
${3}
# Defines a new $scope'd variable inside an AngularJS controller
snippet $v
$scope.${1:variable} = ${2:value}
${3}
# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
snippet $va
$scope.${1:variable} = ${2:variable}
${3}
# Define a $watch for an expression
# You can change the expression to be watched
snippet $w
$scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
${2}
# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
# You can change the event name to listen on
snippet $on
$scope.$on '${1:eventName}', (event, ${2:args}) ->
${3}
# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $b
$scope.$broadcast '${1:eventName}', ${2:eventArgs}
${3}
# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
# You can change the event name and optional event arguments
snippet $e
$scope.$emit '${1:eventName}', ${2:eventArgs}
${3}
## Directive related snippets
# A compile function
snippet ngdcf
compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
${1}
# A linking function in a directive
snippet ngdlf
(scope, element, attrs${1:ctrl}) ->
${2}
# A directive with a compile function
snippet ngdc
directive '${1:directiveName}', factory = (${2:injectables}) ->
directiveDefinitionObject =
${3:directiveAttrs}
compile: compile = (tElement, tAttrs, transclude) ->
(scope, element, attrs) ->
directiveDefinitionObject
# A directive with a linking function only
snippet ngdl
.directive('${1:directiveName}', (${2:directiveDeps}) ->
(scope, element, attrs${3:ctrl}) ->
${4}
)
18 changes: 5 additions & 13 deletions snippets/coffee.snippets → snippets/coffee/coffee.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,8 @@ snippet req
snippet exp
${0:root} = exports ? this


snippet ajax
$.ajax
url: "${1:mydomain.com/url}"
type: "${2:POST}"
dataType: "${3:xml/html/script/json}"
data: ${4:data}
complete: (jqXHR, textStatus) ->
${5:// callback}
success: (data, textStatus, jqXHR) ->
${6:// success callback}
error: (jqXHR, textStatus, errorThrown) ->
${0:// error callback}
snippet jsonp
JSON.parse ${0:jstr}
# JSON.stringify
snippet jsons
JSON.stringify ${0:object}
Loading

0 comments on commit 3f7061a

Please sign in to comment.