Document Base.hyphenate()

This commit is contained in:
Jürg Lehni 2011-12-10 19:57:18 +01:00
parent bc759274a1
commit c8f3f3be27

View file

@ -141,7 +141,7 @@ this.Base = Base.inject(/** @lends Base# */{
}, },
/** /**
* Camelizes the passed string: caps-lock -> capsLock * Camelizes the passed hyphenated string: caps-lock -> capsLock
*/ */
camelize: function(str) { camelize: function(str) {
return str.replace(/-(\w)/g, function(all, chr) { return str.replace(/-(\w)/g, function(all, chr) {
@ -149,6 +149,9 @@ this.Base = Base.inject(/** @lends Base# */{
}); });
}, },
/**
* Converst camelized strings to hyphenated ones: CapsLock -> caps-lock
*/
hyphenate: function(str) { hyphenate: function(str) {
return str.replace(/[a-z][A-Z0-9]|[0-9][a-zA-Z]|[A-Z]{2}[a-z]/g, return str.replace(/[a-z][A-Z0-9]|[0-9][a-zA-Z]|[A-Z]{2}[a-z]/g,
function(match) { function(match) {