Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
feat(generators/component): add split pretty name variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Doğa Gürdal committed Mar 19, 2018
1 parent 49b0a08 commit 9f0fb89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion generators/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ module.exports = class extends Generator {

writing () {
this.namePretty = _.startCase(this.name)
this.namePrettySplit = this._splitPrettyName(this.namePretty)
this.nameKebabCase = _.kebabCase(this.name)
this.nameLowerCamelCase = _.camelCase(this.name)
this.nameUpperCamelCase = _.upperFirst(this.nameLowerCamelCase)
Expand All @@ -125,7 +126,12 @@ module.exports = class extends Generator {
}
}

_writeCustomComponent() {
_splitPrettyName (name) {
const arr = name.split(/(?=[A-Z])/).map(s => s.trim())
return arr.shift() + ': ' + arr.join('')
}

_writeCustomComponent () {
this.log('Creating files...')

const destDir = `${this.themePath}/Components/${this.nameUpperCamelCase}/`
Expand All @@ -140,6 +146,7 @@ module.exports = class extends Generator {
destDir,
{
namePretty: this.namePretty,
namePrettySplit: this.namePrettySplit,
nameKebabCase: this.nameKebabCase,
nameUpperCamelCase: this.nameUpperCamelCase,
nameLowerCamelCase: this.nameLowerCamelCase
Expand Down Expand Up @@ -167,6 +174,7 @@ module.exports = class extends Generator {
destDir,
{
namePretty: this.namePretty,
namePrettySplit: this.namePrettySplit,
nameKebabCase: this.nameKebabCase,
nameUpperCamelCase: this.nameUpperCamelCase,
nameLowerCamelCase: this.nameLowerCamelCase
Expand Down
2 changes: 1 addition & 1 deletion generators/component/templates/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"layout": {
"name": "<%= nameLowerCamelCase %>",
"label": "<%= namePretty %>",
"label": "<%= namePrettySplit %>",
"sub_fields": [

]
Expand Down

0 comments on commit 9f0fb89

Please sign in to comment.