forked from WebDevStudios/generator-plugin-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-wp-base.js
More file actions
42 lines (35 loc) · 1.04 KB
/
Copy pathplugin-wp-base.js
File metadata and controls
42 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var yeoman = require('yeoman-generator');
var updateNotifier = require('update-notifier');
module.exports = yeoman.generators.Base.extend({
constructor: function () {
// Calling the super constructor is important so our generator is correctly set up
yeoman.generators.Base.apply(this, arguments);
updateNotifier({
pkg: require('./package.json')
}).notify({defer: false});
},
_wpClassify: function( s ) {
var words = this._.words( s );
var result = '';
var word;
for ( var i = 0; i < words.length; i += 1 ) {
if ( this._.classify( words[i] ) ) {
result += this._.capitalize( words[i] );
if ( (i + 1) < words.length ) {
result += '_';
}
}
}
return result;
},
_wpClassPrefix: function( s ) {
var words = s.replace( /_/g, ' ' );
var letters = words.replace(/[a-z]/g, '');
var prefix = letters.replace(/\s/g, '');
return prefix + '_';
},
_escapeDoubleQuotes: function( s ) {
return s.replace( /"/g, '\\"');
}
});