Skip to content

Commit 17b1e57

Browse files
authored
Merge pull request #37 from rondale-sc/use-glimmer-in-element
Use `-in-element` to render at appropriate time
2 parents e23fd04 + 5dc82a3 commit 17b1e57

13 files changed

Lines changed: 273 additions & 61 deletions

File tree

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ cache:
1010

1111
env:
1212
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
13-
- EMBER_TRY_SCENARIO=ember-lts-2.4
14-
- EMBER_TRY_SCENARIO=ember-lts-2.8
13+
- EMBER_TRY_SCENARIO=ember-lts-2.12
1514
- EMBER_TRY_SCENARIO=ember-release
1615
- EMBER_TRY_SCENARIO=ember-beta
1716
- EMBER_TRY_SCENARIO=ember-canary

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Install by running
1717
ember install ember-cli-head
1818
```
1919

20+
And add `{{head-layout}}` to the top of your application template.
21+
2022
#### Version
2123
Take into account that version >= 0.3 of this addon require Ember 2.10+ and fastboot >=1.0.rc1
2224
Please use 0.2.X if you don't fulfull both requirements.
@@ -117,4 +119,12 @@ module.exports = function(environment) {
117119
}
118120
```
119121

122+
### Upgrade to 0.4.x
123+
124+
As mentioned above you need to add the `{{head-layout}}` component once and only once in an application wide template. This template is usually `app/templates/application.hbs`, but could be different in your case. Previously, in ember-cli-head 0.3.x and below the component was appended to the document inside an instance initializer. This prevented the need for the `{{head-layout}}` component as it was automatically injected and used inside that initializer. Unfortunately, this approach needed to change so that we could render the component with the rest of the application rendering.
125+
126+
If you care to read more about the details of render please see the PR that introduced these changes https://github.com/ronco/ember-cli-head/pull/37
127+
128+
But for now, if you are upgrading to 0.4.x, you simply need to add `{{head-layout}}` component to your application wide template.
129+
120130
If you make use of this mode the content of `<head>` will be the static FastBoot rendered content through the life of your App.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<meta name="ember-cli-head-start">{{head-content}}<meta name="ember-cli-head-end">
1+
{{#-in-element headElement}}
2+
<meta name="ember-cli-head-start">{{head-content}}<meta name="ember-cli-head-end">
3+
{{/-in-element}}

app/components/head-layout.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ import layout from 'ember-cli-head/templates/components/head-layout';
33

44
export default Ember.Component.extend({
55
tagName: '',
6+
headElement: Ember.computed(function() {
7+
let documentService = Ember.getOwner(this).lookup('service:-document');
8+
return documentService.head;
9+
}),
610
layout
711
});

app/instance-initializers/head-browser.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ENV from '../config/environment';
22

3-
export function initialize(owner) {
3+
export function initialize() {
44
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }
55

66
// clear fast booted head (if any)
@@ -15,9 +15,6 @@ export function initialize(owner) {
1515
document.head.removeChild(startMeta);
1616
document.head.removeChild(endMeta);
1717
}
18-
19-
const component = owner.lookup('component:head-layout');
20-
component.appendTo(document.head);
2118
}
2219

2320
export default {

blueprints/ember-cli-head/index.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
11
/*jshint node:true*/
2+
let fs = require('fs');
3+
let path = require('path');
4+
let chalk = require('chalk');
5+
26
module.exports = {
37
description: '',
4-
normalizeEntityName: function() { }
8+
normalizeEntityName: function() { },
9+
afterInstall() {
10+
let fullPath = path.join(this.project.root, 'app/templates/application.hbs');
11+
12+
if (fs.existsSync(fullPath)) {
13+
let contents = fs.readFileSync(fullPath, { encoding: 'utf-8' });
14+
let toWrite = `{{head-layout}}\n${contents}`;
15+
16+
fs.writeFileSync(fullPath, toWrite, { encoding: 'utf-8' });
17+
} else {
18+
let str = `You must add {{head-layout}} component to your topmost UI.
19+
This is usually your app/templates/application.hbs, but was not found on your system.
20+
Please see the README for more instructions https://github.com/ronco/ember-cli-head#upgrade-to-04x.`
21+
22+
this.ui.writeLine(chalk.yellow(str));
23+
}
24+
}
525

626
// locals: function(options) {
727
// // Return custom template variables here.

config/ember-try.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,10 @@
22
module.exports = {
33
scenarios: [
44
{
5-
name: 'ember-lts-2.4',
6-
bower: {
7-
dependencies: {
8-
'ember': 'components/ember#lts-2-4'
9-
},
10-
resolutions: {
11-
'ember': 'lts-2-4'
12-
}
13-
},
14-
npm: {
15-
devDependencies: {
16-
'ember-source': null
17-
}
18-
}
19-
},
20-
{
21-
name: 'ember-lts-2.8',
22-
bower: {
23-
dependencies: {
24-
'ember': 'components/ember#lts-2-8'
25-
},
26-
resolutions: {
27-
'ember': 'lts-2-8'
28-
}
29-
},
5+
name: 'ember-lts-2.12',
306
npm: {
317
devDependencies: {
32-
'ember-source': null
8+
'ember-source': '~2.12.0'
339
}
3410
}
3511
},
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{head-layout}}
2+
{{outlet}}

fastboot/instance-initializers/head-fastboot.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"ember-cli-app-version": "^1.0.0",
2727
"ember-cli-dependency-checker": "^1.3.0",
2828
"ember-cli-eslint": "^3.0.0",
29+
"ember-cli-fastboot": "^1.0.2",
2930
"ember-cli-htmlbars": "^1.1.1",
3031
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
3132
"ember-cli-inject-live-reload": "^1.4.1",

0 commit comments

Comments
 (0)