Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@magicznyleszek
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magicznyleszek/f268dfd4daada1254e47 to your computer and use it in GitHub Desktop.
Save magicznyleszek/f268dfd4daada1254e47 to your computer and use it in GitHub Desktop.
Atom Snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting tab.
#-------------------------------------------------------------------------------
# CoffeScript
#-------------------------------------------------------------------------------
'.source.coffee':
# create an empty service for module
'Angular service':
'prefix': 'angular-service'
'body': """
angular.module('${1:MODULENAME}').service('${2:SERVICENAME}', [() ->
self = this
self.foo = 'bar'
return this
])
"""
# create an empty model factory for module
'Angular model factory':
'prefix': 'angular-model'
'body': """
angular.module('${1:MODULENAME}').factory('${2:MODELNAME}', [() ->
class ${2:MODELNAME}
constructor: (properties) ->
@id = properties.id
@label = properties.title
@foo = false
fooMe: ->
@foo = true
return ${2:MODELNAME}
])
"""
# create an empty directive for module
'Angular directive':
'prefix': 'angular-directive'
'body': """
angular.module('${1:MODULENAME}').directive('${2:DIRECTIVENAME}', [() ->
class ${3:CLASSNAME}
constructor: ->
@id = null
@element = undefined
@status =
enabled: false
prepare: ->
@status.enabled = true
@create: (properties) ->
instance = new ${3:CLASSNAME}
instance.id = properties.id
instance.element = properties.element
return instance
linkFunction = (scope, $element) ->
self${3:CLASSNAME} = ${3:CLASSNAME}.create({
id: $element[0].id
element: $element
properties: scope.properties
})
init = ->
self${3:CLASSNAME}.prepare()
init()
restrict: 'A'
scope:
properties: '=${2:DIRECTIVENAME}'
link: linkFunction
])
"""
#-------------------------------------------------------------------------------
# SCSS
#-------------------------------------------------------------------------------
'.source.css.scss':
'AMCSS module modifier':
'prefix': 'am'
'body': """
[am-${1:moduleName}~="${2:modifierName}"] {
${3:font: inherit;}
}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment