Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing template-tag feature flag #2080

Merged
merged 7 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'];
}
21 changes: 21 additions & 0 deletions app/locations/trailing-history.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* TODO: Remove this after the upstream PR to allow query params with the trailing history location is merged
* https://github.com/empress/guidemaker/pull/117
*/

/* eslint-disable ember/no-classic-classes, prettier/prettier */
import HistoryLocation from '@ember/routing/history-location';

export default HistoryLocation.extend({
formatURL() {
let url = this._super(...arguments);
return formatURL(url);
},
});

export function formatURL(url) {
let modifiedURL = new URL(url, 'http://example.com');
if (!modifiedURL.pathname.endsWith('/')) {
modifiedURL.pathname += '/';
}
return `${modifiedURL.pathname}${modifiedURL.search}${modifiedURL.hash}`;
}
19 changes: 19 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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]) ?? [],
);
this.features.setupFeatures(Object.assign({}, FEATURES, overrides));
return super.model(params, ...rest);
}
}
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 @@ -87,6 +87,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 @@ -97,6 +113,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
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"eslint-plugin-qunit": "^8.1.2",
"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 Expand Up @@ -138,5 +138,10 @@
"fastbootDependencies": [
"crypto"
],
"packageManager": "[email protected]+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
"packageManager": "[email protected]+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee",
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/guidemaker.patch"
}
}
}
13 changes: 13 additions & 0 deletions patches/guidemaker.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/addon/routes/error.js b/addon/routes/error.js
index 077af09045ae8d59008b10ce53e765561c15dfe7..8156cbcd7dbced7a09eabfddb4381e05a23fd57f 100644
--- a/addon/routes/error.js
+++ b/addon/routes/error.js
@@ -2,4 +2,8 @@ import Route from '@ember/routing/route';

export default class ErrorRoute extends Route {
classNames = ['x404'];
+ setupController(x, error) {
+ console.log(`ended up on ErrorRoute`, error.message, error.stack);
+ super.setupController(...arguments);
+ }
}
Loading
Loading