Skip to content

Commit

Permalink
Merge pull request #14 from rwjblue/use-content-for
Browse files Browse the repository at this point in the history
Honor other addon's content-for hooks.
  • Loading branch information
rwjblue committed Apr 8, 2015
2 parents 038a71d + f706a1e commit 78b79e6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,14 @@ module.exports = {
return {
fastboot: require('./lib/commands/fastboot')
};
},

contentFor: function(type, config) {
// do nothing unless running `ember fastboot` command
if (!process.env.EMBER_CLI_FASTBOOT) { return; }

if (type === 'body') {
return "<!-- EMBER_CLI_FASTBOOT_BODY -->";
}
}
};
4 changes: 1 addition & 3 deletions lib/commands/fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ function findHTMLFile() {
var fs = require('fs');
if (fs.existsSync('app/fastboot.html')) {
return 'app/fastboot.html';
} else if (fs.existsSync('app/index.html')) {
return 'app/index.html';
}

assert("Could not find either app/fastboot.html or app/index.html. Please provide an HTML file to serve FastBoot contents in.", false);
return findFile('html', 'dist/index*.html');
}

function findFile(name, globPath) {
Expand Down
5 changes: 1 addition & 4 deletions lib/models/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ FastBootServer.prototype.log = function(statusCode, message) {
this.ui.writeLine(chalk[color](statusCode) + " " + message);
};

var contentForRegex = /\{\{content-for ['"](.+)["']\}\}/g;

FastBootServer.prototype.insertIntoIndexHTML = function(body) {
var html = this.html.replace("{{content-for 'body'}}", body);
html = html.replace(contentForRegex, '');
var html = this.html.replace("<!-- EMBER_CLI_FASTBOOT_BODY -->", body);

return html;
};
Expand Down

0 comments on commit 78b79e6

Please sign in to comment.