Skip to content

Instantly share code, notes, and snippets.

@jipiboily
Last active August 29, 2015 14:02
Show Gist options
  • Save jipiboily/d4cf750c08085f405e67 to your computer and use it in GitHub Desktop.
Save jipiboily/d4cf750c08085f405e67 to your computer and use it in GitHub Desktop.
Playing with 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.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# RSpec stuff
'.source.ruby':
describe:
prefix: 'desc'
body: """describe '$1' do
$2
end"""
context:
prefix: 'context'
body: """context '$1' do
$2
end"""
'it (lambda style)':
prefix: 'it'
body: 'it { $1 }'
'it (full block)':
prefix: 'it '
body: """it "$1" do
$2
end"""
let:
prefix: 'let'
body: 'let(:$1) { $2 }'
subject:
prefix: 'sub'
body: 'subject { $1 }'
before:
prefix: 'bef'
body: """before do
$1
end"""
# Rails
model:
prefix: 'model'
body: """class ${1:MyModel} < ActiveRecord::Base
$2
end"""
controller:
prefix: 'controller'
body: """class ${1:MyController} < ApplicationController
def index
end
end"""
# Plain Ruby
class:
prefix: 'class'
body: """class ${1:MyClass}
$2
end"""
module:
prefix: 'module'
body: """module ${1:MyModule}
extend ActiveSupport::Concern
included do
end
module ClassMethods
end
end"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment