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

Pro fancy version for coffeeScript syntax #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
117 changes: 117 additions & 0 deletions snippets/computed.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
'.source.coffee':




'Ember Snippets: computed properties':
'prefix': 'computed--help'
'body':
"""
${1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find it unnecessary to have help. The way i see that, snippets shouldn't have that. It should just work by knowledge you already have in mind. If you have to look it up, it will waste time. Can you explain why it's important?

Copy link
Author

Choose a reason for hiding this comment

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

They are written to be used with the knowledge we have already in mind.
But however we as human nonetheless Sometimes Forget.
these help files are just for a quick recap for when we forget or suspect.
Not to be used each time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just feel they would be hard to maintain, and I don't think it's necessary. I'm so-so on the issue, If you feel that it would be important then lets keep them.

# snippets to generate computed properties :
# example: com.lt<press tab>
# ____________________________________________________________________
# | type shorthand -> or long version -> press tab to genetate: |
# | ------------ -> ------------ -> ------------------------- |
# | com.lt -> computed.lt -> Ember.computed.lt(... |
# | com.or -> computed.or -> Ember.computed.or(... |
# | com.gt -> computed.gt -> Ember.computed.gt(... |
# | com.and -> computed.and -> Ember.computed.and(... |
# | com.max -> computed.max -> Ember.computed.max(... |
# | com.min -> computed.min -> Ember.computed.min(... |
# | com.map -> computed.map -> Ember.computed.map(... |
# | com.mapB -> computed.mapB -> Ember.computed.mapBy(... |
# | com.fil -> computed.fil -> Ember.computed.filter(... |
# | com.filB -> computed.filB -> Ember.computed.filterBy(...|
# | com.emp -> computed.emp -> Ember.computed.empty(... |
# |____________________________________________________________________|
#
# *press <Backspace> to remove this quick guide.

}
"""

'Ember computed greater than':
'prefix': 'computed.gt'
'body': "Ember.computed.gt('${1:property}', ${2:0}) ${3:# (returns a boolean)}"


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 please remove all those empty lines, it's unnecessary

Copy link
Author

Choose a reason for hiding this comment

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

removed.



'Ember computed less than':
'prefix': 'computed.lt'
'body': "Ember.computed.lt('${1:property}', ${2:0}) ${3:# (returns a boolean)}"




'Ember computed alias or ':
'prefix': 'computed.or'
'body': "Ember.computed.or('${1:property_1}', '${2:property_2}') ${3:# (returns a boolean)}"




'Ember computed alias and':
'prefix': 'computed.and'
'body': "Ember.computed.and('${1:property_1}', '${2:property_2}') ${3:# (returns a boolean)}"




'Ember computed alias Max':
'prefix': 'computed.max'
'body': "Ember.computed.max('${1:property_1}') ${2:# (returns a number)}"




'Ember computed alias Min':
'prefix': 'computed.min'
'body': "Ember.computed.min('${1:property_1}') ${2:# (returns a number)}"




'Ember computed alias map':
'prefix': 'computed.map'
'body': " Ember.computed.map('${1:array_property}', (item, index) ->
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 change quotations with multiline quotations

${2:#example logic
altered_item = item + "some_string"
return altered_item }

${3:# outputs a new array}
"




'Ember computed alias mapBy':
'prefix': 'computed.mapBy'
'body': " Ember.computed.mapBy('${1:array_of_objs}','${2:obj_key}') ${3:# outputs a simple array[] of items} "




'Ember computed alias filter':
'prefix': 'computed.filter'
'body':
"""
Ember.computed.filter('${1:array_property}', ( item, index, array ) ->
${2:#logic...
# return true (or false) }
"""




'Ember computed alias filterBy':
'prefix': 'computed.filterBy'
'body': "Ember.computed.filterBy('${1:array_of_objs}','${2:obj_key}', ${3:value}) ${4:#returns filtered array[]}"




'Ember computed alias empty':
'prefix': 'computed.empty'
'body': "Ember.computed.empty('${1:propery}') ${2:#returns boolean}"
62 changes: 62 additions & 0 deletions snippets/controller.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'.source.coffee':


'available in model':
'prefix': 'arrayController--help'
'body':
"""
${1:
# you can use these snippets in a arrayController function.
#
# DS.arrayController.extend(
# example : iC<tab>
# _______________________________________________________________
# | type shorthand -> or long version -> press tab to see: |
# | ----------- -> ------------- -> ------------------ |
# | iC -> itemController -> itemController... |
# | sP -> sortProperties -> sortProperties... |
# | sA -> sortAscending -> sortAscending... |
# |_______________________________________________________________|
# )
# *press <Backspace> to remove this quick guide.

}
"""


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




'Ember Array Controller':
'prefix': 'arrayController'
'body':
"""
_export = Ember.ArrayController.extend(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is way complicated. Can we simplify this, to make it just the bare minimum. It should only contain body

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I just had forgotten to delete them.
thank you.

${4:actions:
${5:name_1}: ->
${6:#logic...}
}
)

"""

'itemController':
'prefix': 'itemController'
'body': "itemController : '${1:an_objController}'}"

'sortProperties':
'prefix': 'sortProperties'
'body': "sortProperties : ['${1:property}']}"

'sortAscending':
'prefix': 'sortAscending'
'body': "sortAscending : ['${1:false}']}"
74 changes: 74 additions & 0 deletions snippets/es6.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'.source.coffee':

'Ember Snippets for es6 syntax':
'prefix': 'es6--help'
'body':
"""
${1:
# snippets to generate --ES6 syntax--
# example: imp-ds<press tab>
# ___________________________________________________________
# | type short (or) long version -> then press <tab> |
# | ---------- -> --------------- -> ----------------------|
# | imp-ds -> import-ds -> `import DS... ` |
# | imp-emb -> import-ember -> `import Ember... ` |
# | exp-def -> export-default -> `export default... ` |
# | es6 -> es6 -> - full set - |
# |___________________________________________________________|
}
"""

'ES6 import Ember':
'prefix': 'import-ember'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just have this as part of generating route, controller, model, ...etc?

Copy link
Author

Choose a reason for hiding this comment

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

They are meant to be used in case of when the user forgets or suspects what to type.
I think it is annoying to see them every time,while they are already have got stock in your mind.

Copy link
Author

Choose a reason for hiding this comment

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

keep in mind that the package is written to primarily work with the long version.
it does not force anyone to use or memorize shorthands.
They are just sitting there for seriously lazy people like me to pickup. ;)

/even the zen-coding (or emmet) has such ugly optional shorthands in it./

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not following. I was talking about having an import snippets, why not just have import Ember from "ember" as part of route, controller, model, ...etc?

Why write import, and the route, why not just have it generate import and save you from the hassle

Copy link
Author

Choose a reason for hiding this comment

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

Ahaa,
I tried to create it in a way that it would somehow be compatible with the Global mode of Ember (not just Ember-cli)

'body':
"""
`import Ember from "ember";`
${1}
"""




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




'ES6 export syntax':
'prefix': 'export-default'
'body':
"""

Copy link
Collaborator

Choose a reason for hiding this comment

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

Way too much spacing . Also i don't see this necessary

Copy link
Author

Choose a reason for hiding this comment

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

Good note.
removed.


${2}



`export default ${1:_export};`
"""




'ES6 import and export':
'prefix': 'es6'
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 the point in that either

Copy link
Author

Choose a reason for hiding this comment

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

only because white space allows the content to breath,
easier for human eye to read, rather than a lot of scrambled code.
no technical reason for that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I meant, having es6 snippet

Copy link
Author

Choose a reason for hiding this comment

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

es6 is meant to be used in a blank new file at the start.
then create a (for example) Ember.view.extend in the middle of it
and so on...

'body':
"""
${1:`import Ember from 'ember';`}
${2:`import DS from 'ember-data';`}



${3}



`export default _export;`

"""
51 changes: 51 additions & 0 deletions snippets/logger.cson
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'.source.coffee':

'Ember Snippets: logging functions':
'prefix': 'logger--help'
'body':
"""
${1:
# snippets for Ember.Logger class :
# example : log.err<tab>
# _______________________________________________________________
# | type these -> or long version -> press tab to generate: |
# | ----------- -> -------------- -> ------------------------ |
# | log.err -> logger.error -> Ember.Logger.error(... |
# | log.deb -> logger.debug -> Ember.Logger.debug(... |
# | log.log -> logger.log -> Ember.Logger.log(... |
# | log.inf -> logger.info -> Ember.Logger.info(... |
# | log.war -> logger.warn -> Ember.Logger.warn(... |
# |_______________________________________________________________|
#
# *press <Backspace> to remove this quick guide.

}
"""

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



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



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



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



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


'available in model':
'prefix': 'model--help'
'body':
"""
${1:
# you can use these snippets in a Model function.
#
# DS.Model.extend(
# example : att<tab>
# __________________________________________________________
# | type shorthand -> or long version -> press tab to see: |
# | ----------- -> ------------- -> ------------------ |
# | att -> attr -> DS.attr(... |
# | bel -> belongsTo -> DS.belongsTo(... |
# | has -> hasMany -> DS.hasMany(... |
# |___________________________________________________________|
# )
# *press <Backspace> to remove this quick guide.
}
"""




'Ember Model':
'prefix': 'model'
'body':
"""
_export = DS.Model.extend(
${1:# see more snippets by Expanding :

# model--help${2}
# or model-h for short.
}
)
"""




'Ember Model attributes':
'prefix': 'attr'
'body': "${1}: DS.attr( 'string' ) # or 'number' , 'boolean' , 'date'"




'Ember Model Relation: belongsTo ':
'prefix': 'belongsTo'
'body': "${1} : DS.belongsTo('${2:other_Model}',async: ${3:false})"




'Ember Model Relation: hasMany':
'prefix': 'hasMany'
'body': "${1} : DS.hasMany('${2:other_Model}',async: ${3:false})"
Loading