Created
July 11, 2013 04:41
-
-
Save chenglou/5972583 to your computer and use it in GitHub Desktop.
React coffeescript templater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// globalize everything | |
for (var tag in React.DOM) { | |
if ({}.hasOwnProperty.call(React.DOM, tag) && tag !== 'injection') { | |
window[tag] = (function(tag) { | |
return function(attrs, rest) { | |
if (arguments.length === 1) { | |
return React.DOM[tag](null, attrs); | |
} | |
return React.DOM[tag](attrs, rest); | |
}; | |
})(tag); | |
} | |
} | |
// also allow single argument for custom component | |
var _createClass = React.createClass; | |
React.createClass = function(arg) { | |
var temp = _createClass(arg); | |
return function(attrs, rest) { | |
if (arguments.length === 1) { | |
return temp(null, attrs); | |
} | |
return temp(attrs, rest); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment