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

Improvements for blueprint index.html title removal #179

Merged
Merged
Changes from all 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
24 changes: 12 additions & 12 deletions blueprints/ember-page-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ module.exports = {
let isFastBootPresent = 'ember-cli-fastboot' in project.dependencies();

if (isFastBootPresent) {
let isAddon = 'ember-addon' in project.pkg;

let indexHtmlPath = isAddon ?
let indexHtmlPath = project.isEmberCLIAddon() ?
path.join(project.root, 'tests', 'dummy', 'app', 'index.html') :
path.join(project.root, 'app', 'index.html');

Expand All @@ -26,15 +24,17 @@ module.exports = {
}
);

const titleMatches = contents.match(/<title>(.*)<\/title>/i);
const title = titleMatches[1] || "Example Title";
fs.writeFileSync(
indexHtmlPath,
contents.replace(/\s*<title>.*<\/title>/gi, ''),
{
encoding: 'utf8'
}
);
const titleMatches = contents.match(/<title>\s*(.*)\s*<\/title>/i);
const title = titleMatches && titleMatches[1] || "Example Title";
if (titleMatches) {
fs.writeFileSync(
indexHtmlPath,
contents.replace(/\s*<title>\s*.*\s*<\/title>/gi, ''),
{
encoding: 'utf8'
}
);
}
opts.ui.writeWarnLine(`<title> has been removed from index.html due to ember-cli-fastboot being present, please add {{page-title "${title}"}} to application.hbs`);
}
}
Expand Down