Skip to content

Commit

Permalink
Introducing template-tag feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Dec 3, 2024
1 parent 9a37115 commit ede624b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
5 changes: 5 additions & 0 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import GuideMakerApp from 'guidemaker/controllers/application';

export default class ApplicationController extends GuideMakerApp {
queryParams = ['feature_flags']

Check failure on line 4 in app/controllers/application.js

View workflow job for this annotation

GitHub Actions / Lint files

Insert `;`
}
17 changes: 17 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import GuideMakerApp from 'guidemaker/routes/application';
import { service } from '@ember/service';

const FEATURES = {
'template-tag': false,
};

export default class ApplicationRoute extends GuideMakerApp {
@service features;

model(params, ...rest) {
let { feature_flags } = params;
let overrides = Object.fromEntries(feature_flags?.split(',').map(flag => [flag, true]) ?? []);

Check failure on line 13 in app/routes/application.js

View workflow job for this annotation

GitHub Actions / Lint files

Replace `feature_flags?.split(',').map(flag·=>·[flag,·true])·??·[]` with `⏎······feature_flags?.split(',').map((flag)·=>·[flag,·true])·??·[]⏎····`
this.features.setupFeatures(Object.assign({}, FEATURES, overrides));
return super.model(params, ...rest);
}
}
5 changes: 4 additions & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ module.exports = function (environment) {
modulePrefix: 'ember-guides',
environment,
rootURL: '/',
locationType: 'trailing-history',

// TODO: fix trailing-history to support query params
locationType: 'history',

historySupportMiddleware: true,

EmberENV: {
Expand Down
18 changes: 18 additions & 0 deletions guides/release/getting-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ Congratulations! You just created and booted your first Ember app.

## Write some HTML in a template

<feature-flag-on-template-tag>

We will start by editing the `application` template.
This template is always on screen while the user has your application loaded.
In your editor, open `app/templates/application.gjs` and change it to the following:

```gjs {data-filename=app/templates/application.gjs}
<template>
<h1>PeopleTracker</h1>
{{outlet}}
</template>
```
</feature-flag-on-template-tag>

<feature-flag-off-template-tag>

We will start by editing the `application` template.
This template is always on screen while the user has your application loaded.
In your editor, open `app/templates/application.hbs` and change it to the following:
Expand All @@ -93,6 +109,8 @@ In your editor, open `app/templates/application.hbs` and change it to the follow
{{outlet}}
```

</feature-flag-off-template-tag>

Ember detects the changed file and automatically reloads the page for you in the background.
You should see that the welcome page has been replaced by "PeopleTracker".
You also added an `{{outlet}}` to this page,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"eslint-plugin-qunit": "^7.2.0",
"gfm-code-blocks": "^1.0.0",
"guidemaker": "^4.0.3",
"guidemaker-ember-template": "^4.0.1",
"guidemaker-ember-template": "^4.1.0",
"loader.js": "^4.7.0",
"lodash": "^4.17.21",
"markdown-link-extractor": "1.2.3",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ede624b

Please sign in to comment.