Skip to content

Commit

Permalink
feat: added propper naming convention for backend layouts (issue #46)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZirCon authored and mercs600 committed Jul 9, 2020
1 parent 38457f1 commit b8fe9c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/templates/lib/layouts.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@
function getBackendLayout(components, layout) {
const backendLayout = 'default'
if (layout && layout.length) {
const layoutNameCamelCase = layout.replace(/_([a-z])/g, g => {
return g[1].toUpperCase()
})

if (
Object.prototype.hasOwnProperty.call(
components,
`Be${layout[0].toUpperCase()}${layout.slice(1)}`
`Be${layoutNameCamelCase[0].toUpperCase() +
layoutNameCamelCase.slice(1)}`
)
) {
return layout
// backendLayout names from TYPO3 coming in form of my_backend_layout,
// by replacing the underscores we make sure the tag is generated as be-my-backend-layout
return layout.replace(/_/g, '-')
}
}
return backendLayout
Expand Down

0 comments on commit b8fe9c2

Please sign in to comment.