Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember-cli-coffee-snippets #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions snippets/coffee-adapters.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'.source.coffee':

'Ember fixtureAdapter':
'prefix': 'ds.fixA'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use more clear prefix like fixture-adapter, so it's similar to the rest of the rest of the project. Also please apply this concept to the rest of the prefixes. (rest-adapter, active-adapter)

Can you also move adapters to modules.cson

'body':
"""
export = DS.FixtureAdapter.extend()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add body here, like the rest of your methods

"""

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove extra spacing. Only 1 line between is enough.


'Ember REST Adapter':
'prefix': 'ds.resA'
'body':
"""
_export = DS.RESTAdapter.extend(
${1:#body}
)
"""


'Ember Active Model Adapter':
'prefix': 'ds.actA'
'body':
"""
_export = DS.ActiveModelAdapter.extend(
${1:#body}
)
"""
243 changes: 243 additions & 0 deletions snippets/coffee-ember-object
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@

'.source.coffee':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move merge this file's content with existing snippets based on it's type (function, module, property)


'Ember Route':
'prefix': 'em.rou'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same rule for prefixes too. Please follow my prefixes naming

'body':
"""
_export = Ember.Route.extend(
model: ->
${1:#@store.find("name_of_a_model")}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name_of_a_model -> model_name

)

"""



'Ember Object Controller':
'prefix': 'em.obj'
'body':
"""
_export = Ember.ObjectController.extend(
${1:#body}
)

"""

'Ember Array Controller':
'prefix': 'em.arr'
'body':
"""
_export = Ember.ArrayController.extend(
${1:itemController: 'name_of_an_objectController'}
${2:sortProperties: ['','']}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is too complex. Why sorting and why it requires two actions?

${3:sortAscending: false}
${4:actions:
${5:name}: ->
${6:#logic...}
${7:name2}: ->
${8:#logic2...}
}
)
"""


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove extra lines. Only 1 line should do





'Ember View':
'prefix': 'em.vie'
'body':
"""
_export = Ember.View.extend(
tagName: ${1:"div"}
${2:classNames: ['','']}
${3:classNameBindings: ['','']}
${4:eventManager: Ember.Object.create(
mouseEnter: (event, view) ->
#logic...
return
click: (event, view) ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mouseEnter and click?

#logic...
return
}
)

"""






'Ember Component':
'prefix': 'em.com'
'body':
"""
_export = Ember.Component.extend(
${1:#body}
)

"""






'Ember Mixin':
'prefix': 'em.mix'
'body':
"""
_export = Ember.Mixin.create(
${1:#body}
)

"""






'Ember Object':
'prefix': 'em.obj'
'body':
"""
_export = Ember.Object.extend(
${1:#body}
)

"""






'Ember Helper':
'prefix': 'em.hel'
'body':
"""
_export = Ember.Handlebars.makeBoundHelper( ->
${1:#body}
)

"""






'Ember Model':
'prefix': 'ds.mod'
'body':
"""
_export = DS.Model.extend(
${1:title}: DS.attr(${2:"string"})
${3:title: DS.attr("boolean")}
${4:title: DS.attr("number")}
${5:title: DS.belongsTo('someModel',async: true)}
${6:title: DS.hasMany('someModel' ,async: true)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see need for adding all this as part of model. I believe it's better to have it's separate autocomplete.


)
"""




'Ember REST Serializer':
'prefix': 'ds.resS'
'body':
"""
_export = DS.RESTSerializer.extend(
${1:#body}
)
"""






'Ember Active Model Serializer':
'prefix': 'ds.actS'
'body':
"""
_export = DS.ActiveModelSerializer.extend(
${1:#body}
)
"""




'Ember Transform Serializer':
'prefix': 'ds.tra'
'body':
"""
_export = DS.Transforms.extend(
deserialize: (jsonFromServer) ->
jsonToApp = ${1:#logic...}
jsonToApp

serialize: (jsonFromAppToServer) ->
go2server = ${2:#logic...}
go2server
)
"""



'Ember Initializer':
'prefix': 'em.ini'
'body':
"""
_export = Ember.Application.initializer
name: "put_name_of_this_initializer_here"
${1:after : [
"name_of_other_initializers_to_run_first"
"name_of_other_initializers_to_run_first"
]}

initialize: (container, application) ->
${2:#logic...}
return

${3:before : [
"name_of_other_initializers_to_run_later"
"name_of_other_initializers_to_run_later"
]}

"""



'Ember Utility':
'prefix': 'utility'
'body':
"""
_export = ${1:myUtility} ->
${2:#body}

"""

'Fixture Reopen':
'prefix': 'reo.fix'
'body':
"""
_export.reopenClass FIXTURES: [
{
id: 1
title: "learn ember"
isCompleted: true
author: [10,15,20] #hasMany
author: 12 #bolongTo
}
{

}
]
"""
67 changes: 67 additions & 0 deletions snippets/coffee-functions.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Ember Functions snippets
#
# Examples
#
# `ember<tab>`
#

'.source.coffee':
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move merge this file's content with existing snippets file



'Ember Find by id':
'prefix': 'sto.fin'
'body': "@store.find('${1:model}', params.${1:model}_id)"


'Create Record in Store':
'prefix': 'sto.cre'
'body':
"""
${1:foo} = @store.createRecord('${2:modelType}',
${3:property} : ${4:property}
)
${1:foo}.save()
"""

'delete Record in Store':
'prefix': 'sto.del'
'body':
"""
@store.deleteRecord('${1:modelInstance}')
"""

'fetch Record to Store':
'prefix': 'sto.fet'
'body':
"""
@store.fetch('modelType', params.post_id)
"""

'modelFor':
'prefix': 'modFor'
'body':
"""
@.modelFor('${1:theNameOfParentRoute}').filterBy(${2:properyName})
"""



'Ember Logger Debug':
'prefix': 'log.deb'
'body': "Ember.Logger.debug('${1:message}')"

'Ember Logger Log':
'prefix': 'log.log'
'body': "Ember.Logger.log('${1:message}')"

'Ember Logger Info':
'prefix': 'log.inf'
'body': "Ember.Logger.info('${1:message}')"

'Ember Logger Warn':
'prefix': 'log.war'
'body': "Ember.Logger.warn('${1:message}')"

'Ember Logger Error':
'prefix': 'log.err'
'body': "Ember.Logger.error('${1:message}')"
23 changes: 23 additions & 0 deletions snippets/es6-syntax.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'.source.coffee':

'ES6 import Ember':
'prefix': 'im.emb'
'body':
"""
${1:`import Ember from "ember";`}
"""

'ES6 import DS':
'prefix': 'im.ds'
'body':
"""
${1:`import DS from 'ember-data';`}
"""


'ES6 export syntax':
'prefix': 'ex.def'
'body':
"""
`export default ${1:_export};`
"""