Skip to content

Commit

Permalink
UI/Update blueprints to glimmer components (#13149)
Browse files Browse the repository at this point in the history
* updates generator to glimmer

* adds changelog

* accounts for addon vs reg components

* moves imports to the top of components
  • Loading branch information
hellobontempo authored Nov 16, 2021
1 parent 37c28b4 commit 043172b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
3 changes: 3 additions & 0 deletions changelog/13149.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Updates ember blueprints to glimmer components
```
11 changes: 7 additions & 4 deletions ui/blueprints/component/files/__root__/__path__/__name__.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Component from '@glimmer/component';
<%= importTemplate %>
<%= setComponentTemplate %>
/**
* @module <%= classifiedModuleName %>
* <%= classifiedModuleName %> components are used to...
Expand All @@ -11,7 +14,7 @@
* @param {string} [param1=defaultValue] - param1 is...
*/

import Component from '@ember/component';
<%= importTemplate %>
export default Component.extend({<%= contents %>
});
<%= exportDefault %>class <%= classifiedModuleName %> extends Component {
}

<%= exportAddOn %>
20 changes: 14 additions & 6 deletions ui/blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ module.exports = {
},

locals: function(options) {
let templatePath = '';
let exportDefault = 'export default ';
let exportAddOn = '';
let importTemplate = '';
let contents = '';
let setComponentTemplate = '';
let templatePath = '';

// if we're in an addon, build import statement
// if we're in an addon, build import statement and set layout
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy) || !!options.in) {
if (options.pod) {
templatePath = './template';
Expand All @@ -68,13 +70,19 @@ module.exports = {
'templates/components/' +
stringUtil.dasherize(options.entity.name);
}
importTemplate = "import layout from '" + templatePath + "';\n";
contents = '\n layout';
exportDefault = '';
exportAddOn = `export default setComponentTemplate(layout, ${stringUtil.classify(
options.entity.name
)})`;
importTemplate = "import layout from '" + templatePath + "';";
setComponentTemplate = "import { setComponentTemplate } from '@ember/component'; \n";
}

return {
exportDefault: exportDefault,
exportAddOn: exportAddOn,
importTemplate: importTemplate,
contents: contents,
setComponentTemplate: setComponentTemplate,
path: getPathOption(options),
};
},
Expand Down

0 comments on commit 043172b

Please sign in to comment.