Skip to content
This repository
Browse code

load .server._ templates only on the server

  • Loading branch information...
commit f8bcc1033a4df7971a34a71ab43ffbcd73573822 1 parent 88bb2e8
Konstantin Käfer kkaefer authored

Showing 2 changed files with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  server/plugin.js
  2. +18 0 test/assets.test.js
2  server/plugin.js
@@ -53,7 +53,7 @@ require.extensions['._'] = function(module, filename) {
53 53 }
54 54
55 55 module.exports.register = function(app) {
56   - if (app.assets) {
  56 + if (app.assets && !(/\.server\._$/.test(filename))) {
57 57 app.assets.templates.push({
58 58 filename: filename,
59 59 content: 'template = ' + module.exports + ';'
18 test/assets.test.js
@@ -109,3 +109,21 @@ exports['/assets/bones/views.js'] = function() {
109 109 res.body.indexOf('// ---- start test/fixture/views/App.bones ----'));
110 110 });
111 111 };
  112 +
  113 +exports['/assets/bones/templates.js'] = function() {
  114 + assert.response(server, {
  115 + url: '/assets/bones/templates.js',
  116 + method: 'GET'
  117 + }, { status: 200 }, function(res) {
  118 + assert.ok(res.body.indexOf(require('bones/test/fixture/templates/Error._').toString()) >= 0);
  119 + assert.ok(res.body.indexOf(require('bones/test/fixture/node_modules/othermodule/templates/Other._').toString()) >= 0);
  120 +
  121 + // Doesn't include server files.
  122 + assert.ok(res.body.indexOf(require('bones/test/fixture/templates/ServerSide.server._').toString()) < 0);
  123 +
  124 + // Correct order.
  125 + assert.ok(res.body.indexOf('// ---- start test/fixture/templates/Error._ ----') >= 0);
  126 + assert.ok(res.body.indexOf('// ---- start test/fixture/templates/Error._ ----') >
  127 + res.body.indexOf('// ---- start test/fixture/node_modules/othermodule/templates/Other._ ----'));
  128 + });
  129 +};

0 comments on commit f8bcc10

Please sign in to comment.
Something went wrong with that request. Please try again.