Skip to content

Commit

Permalink
Improve React snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
avdgaag committed May 10, 2015
1 parent 077909d commit 78bd412
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
16 changes: 15 additions & 1 deletion home/.vim/UltiSnips/coffee_react.snippets
@@ -1,7 +1,15 @@
priority -50

global !p
import re
import os
def camelize(str):
return os.path.splitext(''.join([part.capitalize() for part in str.lower().split('_')]))[0]
endglobal

snippet React "React.createClass"
React.createClass
${1:`!p snip.rv = camelize(fn) or 'ClassName'`} = React.createClass
render: ->
$0
endsnippet
Expand Down Expand Up @@ -44,6 +52,12 @@ componentDidUpdate: (prevProps, prevState) ->

endsnippet

snippet :c "componentDidMount" b
componentDidMount: ->
$0

endsnippet

snippet :c "componentWillMount" b
componentWillMount: ->
$0
Expand Down
17 changes: 16 additions & 1 deletion home/.vim/UltiSnips/javascript_react.snippets
@@ -1,7 +1,15 @@
priority -50

global !p
import re
import os
def camelize(str):
return os.path.splitext(''.join([part.capitalize() for part in str.lower().split('_')]))[0]
endglobal

snippet React "React.createClass" b
React.createClass({
var ${1:`!p snip.rv = camelize(fn) or 'ClassName'`} = React.createClass({
render: function() {
$0
}
Expand Down Expand Up @@ -58,6 +66,13 @@ componentWillMount: function() {

endsnippet

snippet :c "componentDidMount" b
componentDidMount: function() {
$0
},

endsnippet

snippet :c "componentWillUnmount" b
componentWillUnmount: function() {
$0
Expand Down

0 comments on commit 78bd412

Please sign in to comment.