Permalink
Browse files

load .server._ templates only on the server

  • Loading branch information...
1 parent 88bb2e8 commit f8bcc1033a4df7971a34a71ab43ffbcd73573822 @kkaefer kkaefer committed Sep 19, 2011
Showing with 19 additions and 1 deletion.
  1. +1 −1 server/plugin.js
  2. +18 −0 test/assets.test.js
View
@@ -53,7 +53,7 @@ require.extensions['._'] = function(module, filename) {
}
module.exports.register = function(app) {
- if (app.assets) {
+ if (app.assets && !(/\.server\._$/.test(filename))) {
app.assets.templates.push({
filename: filename,
content: 'template = ' + module.exports + ';'
View
@@ -109,3 +109,21 @@ exports['/assets/bones/views.js'] = function() {
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.