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

Symlink superhack #14

Merged
merged 5 commits into from
Jan 9, 2015
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ var ifEquals = require('./src/if-equals');

var flagsPromise = flags.init();

// MA: Disgraceful hack to trick symlinks partials to work in not production as this relies on
// knowledge of implementation details that ft-next-express should not be privy to.
if (process.env.NODE_ENV !== 'production') {
var actualExpressHandlebarsPrivateGetDir = expressHandlebars.ExpressHandlebars.prototype._getDir;
expressHandlebars.ExpressHandlebars.prototype._getDir = function() {
var actualExtname = this.extname;
this.extname = "*/*" + actualExtname;
var output = actualExpressHandlebarsPrivateGetDir.apply(this, arguments);
this.extname = actualExtname;
return output;
};
}

module.exports = function(options) {
options = options || {};
var app = express();
Expand Down Expand Up @@ -63,13 +76,13 @@ module.exports = function(options) {

app.use(flags.middleware);

app._listen = app.listen;
var actualAppListen = app.listen;
app.listen = function() {
var args = arguments;
app.use(errorsHandler.middleware);

return flagsPromise.then(function() {
app._listen.apply(app, args);
actualAppListen.apply(app, args);
});
};

Expand Down
1 change: 1 addition & 0 deletions test/fixtures/app/bower_components/linked-dep-1
5 changes: 5 additions & 0 deletions test/fixtures/app/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ <h2>Partials test:-</h2>
<div style="background: yellow">
{{> dep-1/templates/partial }}
</div>

<h2>Symlinked Partials test:-</h2>
<div style="background: yellow">
{{> linked-dep-1/templates/partial }}
</div>
<h2>Dates test:-</h2>
<ul>
<li>Full date: {{#dateformat "dddd, d mmmm, yyyy"}}{{date}}{{/dateformat}}</li>
Expand Down