Skip to content

Instantly share code, notes, and snippets.

@allizad
Created November 21, 2017 17:51
Show Gist options
  • Save allizad/2a6c21c807118f8287e967f1fe2e2687 to your computer and use it in GitHub Desktop.
Save allizad/2a6c21c807118f8287e967f1fe2e2687 to your computer and use it in GitHub Desktop.
My atom snippets configuration
# 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.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
'.source.js':
'log':
'prefix': 'log'
'body': "console.log('$1')"
'react':
'prefix': 'react'
'body': "import React from 'react';"
'proptypes':
'prefix': 'proptypes'
'body': "import PropTypes from 'prop-types';"
'import-fetch':
'prefix': 'ifetch'
'body': "import 'whatwg-fetch;'"
'getfetch':
'prefix': 'getfetch'
'body': """
fetch('$1')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json', json)
}).catch(function(ex) {
console.log('parsing failed', ex)
})
"""
'postfetch':
'prefix': 'postfetch'
'body': """
fetch('$1', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(this.body())
})
"""
'class':
'prefix': 'class'
'body': """
class $1 extends React.Component {
render(){
return (
<div className="_$1"></div>
)
}
}
$1.propTypes = {
}
export default $1;
"""
'constructor':
'prefix': 'constructor'
'body': """
constructor(props) {
super(props);
this.state = {
$1
}
}
"""
'const':
'prefix': 'const'
'body': """
const $1 = (props) => (
<div className="_$1">
</div>
)
export default $1;
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment