Skip to content

Commit

Permalink
load .server._ templates only on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Sep 19, 2011
1 parent 88bb2e8 commit f8bcc10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/plugin.js
Expand Up @@ -53,7 +53,7 @@ require.extensions['._'] = function(module, filename) {
} }


module.exports.register = function(app) { module.exports.register = function(app) {
if (app.assets) { if (app.assets && !(/\.server\._$/.test(filename))) {
app.assets.templates.push({ app.assets.templates.push({
filename: filename, filename: filename,
content: 'template = ' + module.exports + ';' content: 'template = ' + module.exports + ';'
Expand Down
18 changes: 18 additions & 0 deletions test/assets.test.js
Expand Up @@ -109,3 +109,21 @@ exports['/assets/bones/views.js'] = function() {
res.body.indexOf('// ---- start test/fixture/views/App.bones ----')); res.body.indexOf('// ---- start test/fixture/views/App.bones ----'));
}); });
}; };

exports['/assets/bones/templates.js'] = function() {
assert.response(server, {
url: '/assets/bones/templates.js',
method: 'GET'
}, { status: 200 }, function(res) {
assert.ok(res.body.indexOf(require('bones/test/fixture/templates/Error._').toString()) >= 0);
assert.ok(res.body.indexOf(require('bones/test/fixture/node_modules/othermodule/templates/Other._').toString()) >= 0);

// Doesn't include server files.
assert.ok(res.body.indexOf(require('bones/test/fixture/templates/ServerSide.server._').toString()) < 0);

// Correct order.
assert.ok(res.body.indexOf('// ---- start test/fixture/templates/Error._ ----') >= 0);
assert.ok(res.body.indexOf('// ---- start test/fixture/templates/Error._ ----') >
res.body.indexOf('// ---- start test/fixture/node_modules/othermodule/templates/Other._ ----'));
});
};

0 comments on commit f8bcc10

Please sign in to comment.